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 -
Community moderators have prevented the ability to post new answers.
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
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 -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good point. I have added a tip to try to highlight that a bit more.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 -
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.