Is it possible to set a field value in post function?

Volodymyr June 16, 2021

Request:
1. If "Resolution" value is Lost - need to choose a value for the Cause field.
2. If "Resolution" value is not Lost - the Cause field can be left as "None".

I know how to set a specific value for a field in the post function, but here they ask for the ability to select a value from a list type field after transferring to the Lost status.

2 answers

2 accepted

0 votes
Answer accepted
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2021

You will need an addon for automation or scripting. 

Volodymyr June 17, 2021

@Jack Brickey You're right as always. I did it with JMWE app. Thank you.

0 votes
Answer accepted
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2021

Hi Volodymr,

You can jira automation instead.  Take a look at this video on how to do it: https://www.youtube.com/watch?v=S2ary5YG-7w&t=7s 

In your case:

- Trigger: Value Field Change on Resolution field.

- Condition: A condition that checks the resolution field

- Action: Edit Cause field

Regards,

Fabian

Volodymyr June 16, 2021

Hey Fabian,
That will not work for me. We don't have this option in our Jira.

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2021

Hi Again,

I misunderstood your original request.  If you actually want the user to select based on another field, there is a way. 

1. Create a transition screen with the Cause Field and add it to the transition

2. Using Cprime Power Scripts with a  SIL script validator do the following: (You could also use a groovy script as well with any other plugin that provides a validator scripting )

---------------------

if (resolution == "Lost"){

  if (isNull(customfield_rootcause)){  // case when rootcuase is left empty

       return false,  "Error, root cause cannot be empty"

   }

  else {

     return true;

  }

}

else {

 return true; // they can choose any option

}

Conclusion:

- When a user clicks on the transition, the pop up will show up and the validator will show an error message only if the resolution was set to "Lost" and left root cauase is empty.  Note: in this example I'm assuming that the resolution was prior to the transition.

Sil validators details : https://confluence.cprime.io/display/JJUPIN/Customizing+workflows#Customizingworkflows-Forvalidators 

- If you want it to be live where users select on the resolution on the fly, you may want to consider using Live Scripts from Power Scripts: https://confluence.cprime.io/display/JJUPIN/How+Live+Fields+work 

Volodymyr June 17, 2021

@Fabian Lim  Thank you for the detailed instructions. I've done it almost as you described.
I totally forgot that we have JMWE app and your explanation was helpful to do a custom screen and if condition for the required transition.
The result is as easy as this - Fields Required Validator (JMWE app) and condition - issue.get("resolution")?.name == "Lost"
At the end I have this = If "Resolution" field is set to 'Lost', custom field 'Cause' becomes mandatory.

Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2021

Glad to know that it worked.  JMWE, JSU and Power Scripts are all very powerful Add-ons for customized workflows.  

Like Volodymyr likes this

Suggest an answer

Log in or Sign up to answer