Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article provides the code snippet to 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 (JMWE app) post-function.

\uD83D\uDCD8 Instructions

  1. Navigate to the intended workflow to make the necessary changes in the edit modeIn Jira Administration, go to Workflows and click the Edit link to open the workflow.

  2. Select the required transition.

  3. Select the Post Functionstab and click Add post function.

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

  5. Set the following fields:

    1. Field: select the single user picker field

    in “Field” and select “Value type” as
    1. that should be set.

    2. Value type: “Groovy Expression”.

  6. Add the below Groovy script in “Value” Value:

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


    Replace

...

  1. ‘customfield_10300’ on line #4 with the id of the text field

...

  1. which

...

  1. includes the email address to be used in the single picker field.

...

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

...