Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can a Post-Function check values of fields?

jOhn Simonson February 17, 2014

I need a post-function for a transition that sets the value of a custom-field based on the value of another field:

if field('Resolution') in 
    ["Not an issue","Duplicate","Cannot reproduce"]
then 
    field('Source of Issue') = "None"

Is there a way to set up a post-function that can query the value of fields and act accordingly?

ciao - jOhn -

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
February 17, 2014

Your specific case is pretty simple, so there are a number of alternatives. Script runner is free and the script it pretty straightforward in this case.

Update issues (paid) post function is a bit of overkill for this specific case, but can handle more general cases without scripts. Configuration in this case would be:

Condition value: %original_resolution%, condition pattern: (Not an issue)|(Duplicate)|(Cannot reproduce)

Issue entries to update: %original_key%

Set custom field: Source of Issue, value: None

jOhn Simonson February 18, 2014

Thank you very much, I downloaded and tried using "Update issues".

Now it starts to get interesting. I need to use this (for example) when "cancelling" an "Opened" issue, and the transition screen has the "Resolution" field for the user to select his choice.

Thus the "original_resolution" is not that which is relevant, but rather the "selected_resolution" or "future_resolution". I tried using "current_resolution" and "entry_resolution", but did not achieve the desired effect.

I am grateful for any help you can give me.

- jOhn -

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
February 18, 2014

A post function can't cancel a transition - it runs AFTER (post) the transition has occurred. However, you can use the Conditioned validator to do something similar. Validators run BEFORE the transition occurs, have access to the transition variables, and can choose to continue or stop the transition. See Substitution variables and look for transition. Use How to get problem determination information if you have difficulty getting your conditions just right.

jOhn Simonson February 19, 2014

Thanks again for your help - it's working as I planned.

I would suggest that you mention the "transition_" variables in the table at the top of your Substition variables documentation.

- jOhn -

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
February 19, 2014

Good point. I have added a tip to try to highlight that a bit more.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2014

Yes, that's what post-functions are mostly used for.

Are you writing code in a plugin to provide this, or the script runner, or something else?

jOhn Simonson February 17, 2014

I'm a newby at this, so what would be the best way?
(and if you had a link to a good tutorial :) ...

we have installed JIRA Suite Utilities, if that is a help.

thanks - jOhn -

Sandra Meessen April 5, 2018

Hello Nic,  could you help me further on a similar case. My question is similar as John's original one at the top of this questionpage. I have Jira Suite Utilities available. My idea is to put the code in the postfunction of my transition. I'm a new kid in the scriptrunner and groovy class, can you help me with the coding? Would be of great help! Thank you

TAGS
AUG Leaders

Atlassian Community Events