Script Runner to display the executioner out to a custom field defined by each workflow transition

Phet Phosy March 1, 2016

Does anyone have examples to use script runner to automate/define a custom field within a workflow transition so that the executioner gets displayed on that custom field based from each workflow transition?

In a quick nutshell, we are defining our Change Control Process, so that TR/SR/MgrApprovers names get stamped/defined at these new custom fields and from what I was told from our vendors was to use Script Runner.   Any thoughts would be greatly appreciated?  Not sure if this is the right place to ask these questions, so here goes and/or if not, who do I contact?  

5 answers

1 vote
Doug Swartz
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.
March 1, 2016

In addition to the other mentioned options, the JIRA Workflow Toolbox plugin has workflow actions that can do this.

0 votes
Phet Phosy March 1, 2016

Wow~! ... thanks for your splendid feedback, this is great stuff!  Never really used this portal as I've been pretty much just diving in and administrating JIRA by google and such.   I'll come here more often smile

@Phill Fox [Adaptavist]  I'll review your comment and try that out.  For the rest, thank you and greatly appreciate it! 

So Basically ... ;

The objective of the additional fields is to capture who and when the CCP (change control process) was reviewed and approved. The current workflow captures this only in the comment field and if the person didn't leave a comment, then there's no trace of who did what unless once looks at the history tab. To get this going for the team, I've made the comment field as required to get them by though upper management still wants a custom field in place to plugin, so when they pull their reports and such from a dashboard.. that info will be there.  

 

Cheers, 

Phet

Phet Phosy March 2, 2016

Nice!  I'll look into this as well, thank you!

Phet Phosy March 2, 2016

@Doug Swartz ;  how would one go about getting this started?  which post-function do we use basically?  -thank you. 

Doug Swartz
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.
March 2, 2016

In your workflow on the appropriate transition, add a post function.

The simplest JIRA Workflow toolbox function to use is probably the "Copy a parsed text to a field". 

In the parameters screen for the function:

  1. Choose your target field (the field you want to set with the value)
  2. Choose "Basic" parsing mode
  3. In "Text to be parsed..." choose the value "Current User" or "Current User's Full Name" from the selection list below the text box, depending on whether the target field is a string or user
  4. You can also put the current time, or other text into the field, if it's a text field..  
Phet Phosy March 3, 2016

Wow, looks like I have a few options to work with!  Thanks, @Doug Swartz – cheers!

0 votes
Phill Fox
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 1, 2016

See https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/postfunctions/set-issue-attributes.html for how this would work in principle what you would need would be a line similar to 

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();

def userCf = customFieldManager.getCustomFieldObjectByName("<your user field>")

issue.setCustomFieldValue(userCf, currentUser)

0 votes
Boris Georgiev _Appfire_
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.
March 1, 2016

You can do that with script runner but if you want an example on how to do that would you provide some more details, as I'm not really sure what exactly you want to see on the issue view screen ?

  1. What exactly do you expect to see as a custom field value ?
  2. Do you need to display the user who executed some specific transitions or you want to know the user for all transitions ?

The user who executed the transition is stored in the issue history and you can view it without adding a custom field.

 

 

0 votes
Elifcan Cakmak
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.
March 1, 2016

Hello,

If only a specific person (like assignee) can transition the issue, you can use JIRA Suite Utilities' Post Function (Copy Value From Other Field).

https://jsutil.atlassian.net/wiki/display/JSUTIL/JIRA+Suite+Utilities+Workflow+Post-Functions#JIRASuiteUtilitiesWorkflowPost-Functions-CopyValueFromOtherFieldPost-Function

To do this;

  1. you should add a custom field User Picker.
  2. you should add a condition "Only Assignee can transition)
  3. you should add a copy value from other field post function with source assignee and destination your custom field.

 

Suggest an answer

Log in or Sign up to answer