Custom script post-function for holding the transition executed user full name

Hi, We have a workflow like below and a custom filed Addressed By. we need to copy the user id to Addressed by filed using post funtion "Custom script post-function" when ever the issue moved to CLOSED state. when ever the issue moved from 1. open to closed 2. Rejected to closed 3. Reopend to closed 4. validation to closed, the custom field - Addressed By value need to updated to trasition executed user full name.

 

Closed.JPG

Some one please help on the script. which is same like the copy the date from the post - https://community.atlassian.com/t5/JIRA-questions/Scripted-post-function-to-set-a-date-value-in-custom-field/qaq-p/368278  

 

 

 

 

1 answer

1 accepted

This widget could not be displayed.

Hey Ramaiah,

To do this, you'll have to place a post-function on every one of the transitions that you specified above. In each custom post-function, you can get the current user and assign them to the "Addressed By" field using a script like:

import com.atlassian.jira.component.ComponentAccessor

def cfm = ComponentAccessor.getCustomFieldManager()
def jiraAuthContext = ComponentAccessor.getJiraAuthenticationContext()

def userCf = cfm.getCustomFieldObjectByName("Addressed By")
def currentUser = jiraAuthContext.getLoggedInUser()

issue.setCustomFieldValue(userCf, currentUser)

Additionally, you need to make note of where the post function is in the order of execution. Make sure you put this function just before the "Re-index an issue to keep indexes in sync with the database" step:

Screen Shot 2017-06-28 at 8.38.52 AM.png

Let me know if you need help with this or have any more questions! :)

Best,                                                                                                               Aidan

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

229 views 3 0
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