MISC workflow post function - how to get the changed priority value during the issue creation

Ganga_Selvarajah May 24, 2016

I am using following Groovy expression post function to get a priority value and set it to a custom field during a issue creation. 

if(issue.get("priority").getName() == "Minor" || issue.get("priority").getName() == "Trivial")

{
return "Low Priority";
}
else
{
return "TBD";
}

The above groovy expression post function is working for issue created manually, but it is not working if a issue created via Remedy.

How do I extend above groovy expression to check that, priority value has changed during a issue creation via Remedy. (Please see the attached)

 

Cheers,

Ganga

image2016-5-25 15:19:24.png

3 answers

1 vote
David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2016

Did you check your logs (atlassian-jira.log) for errors or warnings right after creating the issue from Remedy?

You can also add some logging to your script using the log object to find out what the priority field contains when the post-function runs:

log.error("Priority is: "+issue.get("priority").getName());

Also, make sure the priority field is not simply empty (null) at the beginning of your script:

if (issue.get("priority")==null) {
	log.error("Priority field is empty");
    return;
}
Ganga_Selvarajah May 25, 2016

Hi David,

Thanks a lot your suggestion.

The priority field always has a value (default is = Major). Via remedy interface we're getting priority value. it is get updated correctly for a newly created issues, but set value Groovy expression post function is taking a default value (Major) instated changed value.

how do I get the changed value?

 

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2016

I have no idea how Remedy updates that value and when, so I cannot help you unless you elaborate.

Ganga_Selvarajah May 25, 2016

a log information will it help you to see the issue?

here is the screenshot of the issue history tab. The values comes from Remedy (Region, Priority & Case Id)

 

image2016-5-26 10:58:44.png

Ganga_Selvarajah May 25, 2016

during the issue creation the priority value changed from Major to Minor, but Groovy expression script is always getting original value. In this case, it is "Major"

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2016

Judging from the history, the priority is changed AFTER issue creation (hence the "original value"). This is why the post-function, which runs DURING issue creation, doesn't see the changed value.

So you need to investigate how this synchronization with Remedy works, and if you can modify the custom field during that sync.

Ganga_Selvarajah May 25, 2016

Actually, priority field changed during a issue creation.

In JIRA default priority is set to Major, so that during the issue creation priority value has changed from Major to Minor.

if there any way to get a new value through the Groovy expression script?

 

 

 

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2016

Well, I can guarantee you, with absolute certainty, that the priority field is not changed during the Create transition. It is likely updated by an event listener that reacts to the Issue Created event, but it takes place immediately after issue creation so you don't notice it.

The reason why I am positive is that otherwise you wouldn't see an entry in the issue history. And the other reason why I'm sure is because I see no post-function that would handle that synchronization with Remedy.

So, since the Set Field Value post-function runs during the Create transition, it cannot see the updated value.

However, what you can do is create an "auto-transition", from the first Status of your workflow onto itself, hidden by the Hide Transition condition, and on that transition you place the set field value post-function. Finally, you trigger that transition automatically at the end of the Create transition using the Transition Issue post-function.

Ganga_Selvarajah May 25, 2016

Hi David,

firstly: Thanks for your time to help me on this issue.  I followed your steps, but auto transition is not executed. Am I doing some thing wrong here? please see the attached...

image2016-5-26 13:36:47.png

 

 

 

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2016

I can't see the bottom of your screenshot, so I can't see how you trigger the "Auto transition" from the Create transition. Note by the way that you don't need to call it "Auto Transition" wink

Try first removing the "Hide Transition" condition and see if it then works.

Ganga_Selvarajah May 26, 2016

didn't work after removed the "Hide Transition" condition. I can see "Auto Transition" button is visible after removed the Hide Transition condition.

Please see the create and auto transition screenshots.

image2016-5-27 9:13:47.png

image2016-5-27 9:16:33.png

David _old account_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2016

Are you certain of the transition ID for your "Auto Transition" transition? Can you try with the transition name instead?

Also, on the Create transition, try moving the Transition Issue post-function to the end of the list.

Ganga_Selvarajah May 26, 2016

It works perfectly after moved Transition Issue post function to the end of the list.

Thanks a lot for your time to resolve this issue. I believe most of users definitely get benefits from your solution.

Cheers,

Ganga

 

 

1 vote
viktorokolot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 24, 2016

Hi @Ganga Selvarajah

please move your post-function (3. Creates the issue originally.) on first place and check

Ganga_Selvarajah May 25, 2016

Thanks, sorry for the late response. 

 

I tried, but no luck....

0 votes
Ganga_Selvarajah May 26, 2016

It works perfectly after move Transaction Issue post function to the end of the list.

Thanks a lot for your time for me to resolve this issue. I believe lots other users definitely get benefits from your answer. 

Cheers,

Ganga

 

Suggest an answer

Log in or Sign up to answer