first(fieldHistory(%{Assignee})) returns always zero
It seems like fieldHistory returns comma separated string instead of String List, because the following expression works: first(toStringList(toString(fieldHistory(%{Assignee})),","))
Comments (13)
-
repo owner -
reporter Thanks a lot, Fidel! It was not evident from the documentation.
Fidel, is there a way to get to know the latest assignee of the issue in some status? I really need this function, can't finish my auto-assign scheme without it.
-
reporter Fidel, I have one more question regarding fieldHistory. It seems like it doesn't keep history for assigned from post-function.
So in my case I want to assign issue:
in To Do - first Assignee
In QA - custom_field_Assigned_QA.value
Here is the problem:
-
Create an issue and assign it
-
Transition to QA, issue auto-assigned to the field value
-
Transition to To Do - fieldHistory(Assign) is empty, I can't assign back to First Assignee
Please, advice how I can do this. I think it'd be better to keep all assignee in the fieldHistory, including first and all post-function assigned. Is it possible?
-
-
repo owner Hi Andrey, which post-function are you using in transition 2 to assign issue to custom field value?
-
reporter Fidel, for step 2 I use Set a field as a function of other fields Function, example. Highlighted row doesn't work, because it doesn't catch either first manual assignee or assignee from post-functions.
I'd like to implement two algorithms.
- Assign issue to the very first assignee (no matter was it manual or auto) - can't do that because fieldHistory() doesn't catch both cases.
- Assign issue to the last assignee in the status - can't do that because there is no function to get to know the last assignee of a status.
So I'd like to have the following. 1. fieldHistory() catch each and every assignee. 2. statusLastAssignee(status) - who was assigned, returns empty for "unassigned" or "user". Or some assignee/status historical function.
-
repo owner I Andrey,
In my test fieldHistory() is correctly retrieving assignees set by JIRA Workflow Toolbox post-functions. I show you my test configuration and result:
Transition "Create Issue":
Creating a test issue:
Result obtained in issue Description:
The result obtained are the first two assignees (newton and feynman), and the current assignee is not returned.
In case you are working with "Create Issue" transition, it's very important that you move post-function "Creates the issue originally" to first position in execution order. Please, check it up.
-
reporter Fidel. it seems like I found an error (in 2.2.6.1).
- This is an example of my assign step in every status.
- This is a debug function.
- This is the result after several transactions (the first assignment was manual, others - automatic via post-functions)
Please pay attention at the comma in the beginning of the string. That is why my function doesn't work - it tries to assign an empty value. Please investigate.
P.S. What about the last assignee in the status? Will it be possible to add this function?
-
reporter It's strange that I cannot see a comma in your example and see at my example. Just checked - I get the same result (with comma) even for manual assignments only.
-
repo owner That comma is due to an empty string (i.e., "") at first position in the string list, which is due to the issue being unassigned just after creation. In my case the issue is always assigned to a user.
In the function documentation this behavior is explained in a general manner:
-
reporter Got it, thank you, Fidel.
Sorry to be persistent, what about "the last assignee in status function"?
-
repo owner In relation to your second requirement, I have to work on it. I would like to design a more general solution, where it is possible to do any query on the issue history.
I hope I can something more concrete soon.
Meanwhile, isn't it possible to that you use a hidden custom field, that you would set using a post-function in each transition with origin in the status you want to register its last assignee? I think that this workaround should work for you, and is not too annoying to implement.
-
reporter I believe more general solutions would be better )
Thank you for the suggestion, will try to implement it.
-
reporter - changed status to resolved
- Log in to comment
Hi Andrey,
There isn't any bug here. I explain each term of the expression:
returns a string list.
returns a string with a comma separated of values.
returns a string list again.
You can use the following simpler and equivalent expression:
but since fieldHistory(%{00003}) might return an empty list, and first() applied to an empty list will throw and error, you should use the following expression:
Note that %{00003} is field code for Assignee.