Copy a parsed text to a field error
Hi, Fidel!
This following function doesn't make any comments: https://www.screencast.com/t/hMGffclgO
If I remove a middle string (lastAssignee) it works: https://www.screencast.com/t/XixNmmV7
Comments (22)
-
reporter -
repo owner Hi Andrey,
I have tried to reproduce your problem without success. I have tried in JIRA 6.2.3 and JIRA 7.3.2 with a normal reflexive transition, and with a global reflexive transition, and in both cases function lastAssigneeInRole() is working as expected.
Please, check your log file for errors.
Thanks.
-
reporter I've just checked - no any error messages. Here is a full post-function:
"1: " + %{00014} + ": " + %{00016} + " Assignee" + "\n" + "2: " + projectProperty(%{00014} + ": " + %{00016} + " Assignee") + "\n" + "la: " + lastAssigneeInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) + "\n" + "du: " + defaultUserForRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) + "\n" + "us: " + toString(usersInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")))
Here is a project parameter:
{Construction: Site Survey Assignee=Field Team}
"Field team" project role has one user. No one was assigned to the issue, it's just created.
-
reporter In the same transition, the following post-function doesn't work
set Assignee to:
projectProperty(%{00014} + ": " + %{00016} + " Assignee") = null ? %{00003} : (defaultUserForRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) != null ? defaultUserForRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) : (toString(usersInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee"))) = "" ? %{00003} : nthElement(usersInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")), 1)))
If I remove a part with defaultUserForRole - it works, it assigns the issue to the first user. There is no default user for this project role.
-
reporter This is "from any to itself" transition: https://www.screencast.com/t/wKyIVCTwrjW2
-
reporter We have JIRA 7.3.1 installed
-
reporter This is the transition post-functions, neither first no second post-functions work: https://www.screencast.com/t/5tYzuU4KJKTQ, just checked, no any errors
-
reporter I think I found why the first post-function doesn't work, it doesn't like string + null expression. If I replace with the following, it works:
"la: " + (lastAssigneeInRole(projectProperty(%{00016} + " Assignee")) = null ? "null" : lastAssigneeInRole(projectProperty(%{00016} + " Assignee")))
-
reporter It's interesting because defaultUserForRole works fine, despite it also returns null value:
"1: " + %{00014} + ": " + %{00016} + " Assignee" + "\n" + "2: " + projectProperty(%{00014} + ": " + %{00016} + " Assignee") + "\n" + "la: " + (lastAssigneeInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) != null ? lastAssigneeInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) : "") + "\n" + "du: " + defaultUserForRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")) + "\n" + "us: " + toString(usersInRole(projectProperty(%{00014} + ": " + %{00016} + " Assignee")))
It makes the following comment:
1: Construction: Site Survey Assignee 2: Field Team la: du: us: test-billing
-
reporter It seems like I found an error: defaultUserForRole returns empty string "" instead of null when there is no default user.
-
reporter It seems like I found yet another issue: when you pass to lastAssigneeInRole null value, it throws an error in logs, while defaultUserForRole throws a warning.
-
repo owner Hi Andrey,
Thank you this great work. I will try to solve the problems as soon as possible.
-
repo owner Hi Andrey,
Version 2.2.33_beta_2 has the following changes:
- lastAssigneeInRole() returns an empty string when no user is returned. This change in behavior shouldn't cause back-compatibility problems since comparing an empty string with null returns true, i.e. "" = null returns true.
- lastAssigneeInRole(null) now shows a controlled error message, like defaultUserForRole(null).
-
reporter Have you considered that
- In the documentation said it should return null.
- lastAssigneeInRole != null will not work.
I think it'd be better to change defaultUserForRole to return null as in documentation. What do you think?
-
repo owner Historically the language has considered "" equivalent to null. I know it's not a good idea, but it can't be changed in order to keep back-compatibility with all the legacy code.
lastAssigneeInRole() != null will work the same way, since "" and null is the same for comparison operators.
-
reporter Fidel, I've just checked the beta and can say that lastAssigneeInRole() != null does NOT work as != "". That might lead to compatibility issues.
These are post-functions: https://www.screencast.com/t/VfgVLPxiEW Theis is the output: https://www.screencast.com/t/9dwVCZAeQa
As you can see, lastAssignee is empty (issue just created), but lastAssignee != null is true.
-
reporter The same with defaultUser(), so expression "" != null is true, and it might be a problem.
-
repo owner Hi Andrey,
Sorry for my mistake. I had already detected the problem in the regression automated test of the plugin. You are completely right.
lastAssigneeInRole() will keep returning null in the definitive version 2.2.33.
I'm working in the following changes:
- String concatenation operator + will not fail when second operand returns a null. In those cases it will behave like if it were returning an empty string.
- I'm updating the parser's documentation, since functions userProperty(), defaultUserForRole() and leastBusyUserInRole() actually return an empty string instead of null, as it's currently stated in the documentation. I will keep the current behavior to keep back compatibility. I'm also adding automated tests in order to guarantee that any future change on this will be detected.
I was confused by the fact that comparisons of a string field code with null in fact treat null and empty string as if it where the same thing. This is the only special treatment of null implemented by the language.
-
reporter In the last sentence, you said that null and empty string are the same, but null is not equal to the empty string and comparison will return false.
Then I need to change my algorithm for lastAssignee returning null. Please let me know if you have any beta where I can test that.
Is it possible to have an empty string and null equal? It'd solve the issue.
-
repo owner Hi Andrey,
You are right, null is not the same as empty string. JIRA Workflow Toolbox 2.2.33_beta_3 is almost the version ready to be released. In this version lastAssigneeInRole() returns null when the issue has never been assigned to a user with the role.
-
repo owner - changed status to resolved
Fixed in just released version 2.2.33.
-
reporter I've just tested 2.2.33, it works as expected.
- Log in to comment
BTW, it's happening from itself to itself transition. Also, it seems like lastAssigneeInRole brakes other functions.