Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Set a single user picker field from the email address available in a free text field

It is possible to extract an email address from a free text field and then use that email address in a single user picker field.

This article provides the code snippet to accomplish this using the Set field value post-function.

 Instructions

  1. In Jira Administration, go to Workflows and click the Edit link to open the workflow.

  2. Select the required transition.

  3. Select the Post Functions tab and click Add post function.

  4. Select the “Set field value (JMWE app)” post-function and click Add.

  5. Set the following fields:

    1. Field: select the single user picker field that should be set.

    2. Value type: “Groovy Expression”.

  6. Add the below Groovy script in Value:

    import com.atlassian.jira.bc.user.search.UserSearchService def userSearchService = ComponentAccessor.getComponent(UserSearchService) def users = userSearchService.findUsersByEmail(issue.getAsString("customfield_10300")) users[0]


    Replace ‘customfield_10300’ on line #4 with the id of the text field which includes the email address to be used in the single picker field.

  7. Click Add and publish your workflow.

Please note: The above script can return null in one of two scenarios:

  1. The source text field (e.g. ‘customfield_10300’ in the above example) is empty.

  2. No user is found for the email address present in the source text field.

 

References