Skip to content

Fix - Default tech in Tasks Templates #19427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RomainLvr
Copy link
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !37234
  • Here is a brief description of what this PR does

In task templates, when the "By" parameter is left empty, selecting that template in the ticket task creation form should result in the "Technician" field being empty as well. However, the current behavior incorrectly assigns the logged-in user as the technician. This PR fixes the issue so that the "Technician" field correctly remains empty, respecting the task template configuration.

Rollback a part of this PR : #17360

@RomainLvr RomainLvr self-assigned this Apr 10, 2025
@RomainLvr RomainLvr requested a review from stonebuzz April 10, 2025 15:19
@cconard96
Copy link
Contributor

This doesn't seem logical to me. If I create a task template, I expect it to show as my task when used. Only in very specific circumstances could I see overriding the task author in a template as useful. Therefore, using the current user should be the default if not specified rather than having a task show as written by nobody.

@stonebuzz
Copy link
Contributor

This doesn't seem logical to me. If I create a task template, I expect it to show as my task when used. Only in very specific circumstances could I see overriding the task author in a template as useful. Therefore, using the current user should be the default if not specified rather than having a task show as written by nobody.

The purpose of this Pull Request is to restore the default behavior of GLPI, which is: if no actor is specified in the template, GLPI defaults to the logged-in user.

The PR mentioned by Romain removed this default behavior. Now, if no actor is specified in the template, no actor is selected in the task, which has led to support requests.

I understand that leaving the template field empty should result in an empty task field. However, there is a need for the option to set the logged-in user as the default when selecting the template.

To address this, I propose adding a new option in the by field of the template: ["-1" => "Current logged-in user"]. This way, we would have all the following possibilities:

  • Empty by field in the template -> Empty "by" field in the task.
  • by field set to "Current logged-in user" -> Current logged-in user in the task.
  • by field set to a specific user -> Specific user in the task.

@trasher
Copy link
Contributor

trasher commented Apr 14, 2025

[...]
To address this, I propose adding a new option in the by field of the template: ["-1" => "Current logged-in user"]. This way, we would have all the following possibilities:

* Empty `by` field in the template -> Empty "by" field in the task.

* `by` field set to "Current logged-in user" -> Current logged-in user in the task.

* `by` field set to a specific user -> Specific user in the task.

This looks like correct to me. @cconard96 are you OK with this proposal?

@RomainLvr
Copy link
Contributor Author

The option has been added and the behavior works, but there's still a problem with the display of this new value in the list of task templates.

For example, the By field in the first template is Current logged-in user, but the value displayed is empty.

image

@stonebuzz stonebuzz requested a review from trasher April 14, 2025 09:31
@cconard96
Copy link
Contributor

cconard96 commented Apr 14, 2025

The purpose of this Pull Request is to restore the default behavior of GLPI, which is: if no actor is specified in the template, GLPI defaults to the logged-in user.

That isn't what the PR description said though.

In task templates, when the "By" parameter is left empty, selecting that template in the ticket task creation form should result in the "Technician" field being empty as well. However, the current behavior incorrectly assigns the logged-in user as the technician.

That description makes it sound like not setting a technician in the template should result in the task not having a technician instead of the current behavior which has the task author as the current user by default.

To address this, I propose adding a new option in the by field of the template

I can't think of a legitimate reason for tasks to have no technician assigned or for the default, empty value for a template to result in a task with no technician assigned.

@cedric-anne cedric-anne added this to the 11.0.0 milestone Apr 16, 2025
@RomainLvr RomainLvr force-pushed the fix/task-template-tech branch from 35f8dcb to 3341ba8 Compare April 16, 2025 09:23
@RomainLvr RomainLvr requested a review from Rom1-B April 17, 2025 08:49
Copy link
Contributor

@Rom1-B Rom1-B left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests (surprising that it hasn't already been requested — not naming anyone 😄).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants