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

  2. Select the required transition.

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

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

  5. Select the target single user picker field in “Field” and select “Value type” as “Groovy Expression”.

  6. Add the below Groovy script in “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 10300 in line #4 with the id of the text field, which has the email address.

...

  1. The text field is empty.

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

References

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@22cf51
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel in ( "groovy" , "script" , "jmwe-datacenter" , "jmwe-server" , "jmwe-postfunction" , "user-picker-field" ) and type = "page" and space = "JMWE"
labelskb-how-to-article