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

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

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.

 

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.

 

 

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)

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

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

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

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..  

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

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

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

784 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you