Hi, I have a small query.
I have a post function script in a workflow transition according to which if that script executes successfully and an output is gained then transition from A->B goes through successfully. If not, then it stays at A.
Is is possible?
Hello,
you might want to do it with a validator (or a condition), but not with a post-function
If it's a post-function, it's too late, the transition is almost complete
If it's a validator, then yes, you can return a pass or fail
You do NOT want a condition. It will be run every time JIRA looks at the issue to see if a user can use it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi NIc,
Thanks for the confirmation. How can I implement the same through a validator. I will try to explain the whole scenario:
I have a groovy script, which shoots a curl command to Service Now, and gives an output in my JIRA logs. Based on that output, i want to make sure that the transition goes from A->B or stays at A.
My approach:
I have a custom field which gets populated in my JIRA ticket screen with the result of the grovy script mentioned above. So my requirement is, if custom field gets populated with value X then A->B should take place, if not(e.g. value Y) then transition stays at A.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You will need to embed your script in a validator.
Are you using the script runner add-on? If not, then you're going to need to write a validator that can run your connection and interpret the result as a pass/fail.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic, I am using this scriplet in my Validator, but still not working, can you pls suggest:
if(finalOutput.contains("[inserted]"))
{
log.debug("Inside incident block");
//def servicenowid = customFieldManager2.getCustomFieldObjectByName("ServiceNow ID");
//log.debug("Service id=$servicenowid")
log.debug("Inside incident block");
issue.setCustomFieldValue(servicenowidfield,finalIncident);
workflowTransitionUtil.setAction (1531);//Transition B
}
else
{
log.debug("Inside Else block");
issue.setCustomFieldValue(servicenowidfield,"Not Created in Service Now");
workflowTransitionUtil.setAction (4);//Transition A
}
How can I optimize this script to the above condition?
As of now, my script is anyways going to B irrespective of the fact that it catches the else block only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, hang on, that's not what we were discussing.
You do NOT try to change the target of a transition while it's running. And there's absolutely no way you should be even thinking of changing an issue in a validator.
A validator should validate something, returning "true" if it's ok, and "false" (with an optional error message) if it fails validation.
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.