Add members of a group selected in a Group picker (single) field as Watchers of a ticket.

This article provides the code snippet to add members of a group selected in a “Group Picker (single group)” field as Watchers of a ticket using JMWE post-function.

 Instructions

  1. Navigate to the intended workflow and open it in Edit mode.

  2. Select the required transition.

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

  4. Add the post-function.

  5. Select the issue(s) to which the Watchers should be set under “Target Issue(s)”.

  6. Select the “Watchers” field and add the below Nunjucks template:

    {{ issue.fields.customfield_10040 | field("groupId") | groupMembers | field("accountId") }}

    Replace 10040 with the ID of the Group Picker (single group) custom field.

JMWE Set Issue Fields post-function

Publish the workflow for the changes to be applied as configured and select a backup copy before publishing the new changes.

 

If this post-function is added on the create transition, select the checkbox “Delay the execution of this post-function” under “Delayed execution” and select a delay of 3 seconds.

References