Howto get Smart Value for groupId from custom single groupPicker field
Asked by Tim:

Hi there,

I'm new to Jira Automation (Cloud) and trying to create an automation rule that creates subtasks for users in a selected group from a custom single group field. yep, not an easy task for a beginner...

***What I try to achieve***

![completeRule.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322383iC1D929F55629745B/image-size/large?v=v2&px=999 "completeRule.jpg")

This screenshot shows my idea how to achieve my goal, but is not finished yet.

However, I managed to iterate over a given hardcoded groupName (in web request) and get users from it to create the subtasks.

Assume the variable groupName is a group name with spaces in it. Unfortunately <https://mydomain.atlassian.net/rest/api/3/group/member?groupname={{groupName>}} only works if the group has no spaces in it.

![webrequest.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322381i378B28E1B4BA7F2D/image-size/large?v=v2&px=999 "webrequest.jpg")Obviously it must be encoded for use in url, and I until now I was not able to do this.

So I decided to us the group id and request the api: <https://mydomain.atlassian.net/rest/api/3/group/member?groupId=123456789>

This might work with a single, harcoded groupid in Web request URL.

***My Problem***

However, my problem is quite simple: When I switch from hardcoded groupId/groupname (in web request url) to retrieving groupId from custom single group field, the value is always null.

![groupPicker Single Group.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322380iE0B92E3CFEE21E57/image-size/large?v=v2&px=999 "groupPicker Single Group.jpg")

My custom field has the name "Training Group" with the field id "customfield_10322".

![customField single group.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322379iF0C5EFF00B755878/image-size/large?v=v2&px=999 "customField single group.jpg")

"<https://mydomain.atlassian.net/rest/api/3/issue/>\<issue-key\>?expand=names" shows that the following attributes are available for customfield_10322

*"customfield_10322": {*   
*"groupId": "123456789",*   
*"name": "Training group",*   
*"self": "<https://mydomain.atlassian.net/rest/api/3/group?groupId=123456789>"*   
*},*

However, I can't get the groupId attribute via smart value. The value is always null.

![2024-05-07 17_05_00-Clipboard.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322375i1961A2791BA96FAB/image-size/large?v=v2&px=999 "2024-05-07 17_05_00-Clipboard.jpg")

Neither with SmartValue {{issue.customfield_10322}} nor {{issue.customfield_10322.groupId}} or {{issue.fields.customfield_10322.groupId}}.

To simplify things, I've created a manually triggered rule that logs to the audit log.

![automation rule.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322376iF35474CD711178BE/image-size/large?v=v2&px=999 "automation rule.jpg")

I'm curious to know what's my mistake and would really appreciate your tips.

If there is a better or simpler solution for my goal I would like to hear your suggestions.

Thanks in advance, this is driving me crazy for hours...

Regards, Tim


Answers:
author: Bill Sheboy
body: Hi [@Tim](/t5/user/viewprofilepage/user-id/5062331)

First thing, well done trying to diagnose this one for your rule!

This seems to be a known problem, and here is a suggestion to fix it: <https://jira.atlassian.com/browse/AUTO-890>

Your workaround could be to use the group name to get the users, adding the urlEncode() function to manage the embedded spaces:

<https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#urlEncode-->

Kind regards,  
Bill

comments: author: Tim
body: Hi Bill,

Thanks for your help. I've been looking for this kind of "bug" ticket with no success. Glad to see this one is already created (+Vote and comment added).

The workaround is great! I tried playing around with the smart value text functions until I realised that they only work when I get {{issue.customfield_10322.name}}. If I only get {{issue.customfield_10322}}, the name is logged in the audit log, but the functions do not work.

![getEncode.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322532i9FCD096AA3A8A1D8/image-size/large?v=v2&px=999 "getEncode.jpg")

![auditLog.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322533i80918EC8C9B92974/image-size/large?v=v2&px=999 "auditLog.jpg")

Best regards,

Tim


author: Tim
body: Edit: Updated automation rule with conditions to check if the web requests return values (not empty) and if subtasks habe already been created (no check for specific subtask).

That was fun, Jira automation is quite powerful, but hard to master. Thanks again for your help, Bill!

For documentation purpose, here's the complete rule. This one works for my needs (number of groupmembers \< 50).

If

* an issue is a task
* and the issue is transitioned from "To Do" into "In progress"

the following rule

* creates subtasks
  * for each group member of a choosen group from a custom single group picker field
* assigns the created subtask to the respective group member
* and writes the displayname from the respective member account into summary field.

![automation rule.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323679i124AE380C7202FCE/image-size/large?v=v2&px=999 "automation rule.jpg")

![2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322544i1C57A8E8FA5C837F/image-size/large?v=v2&px=999 "2.jpg")![3.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322543iA0E77491AAF1FCB6/image-size/large?v=v2&px=999 "3.jpg")![4.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322545i21F5E47A6211F64D/image-size/large?v=v2&px=999 "4.jpg")![5.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322547i4056AB37C62FDDFE/image-size/large?v=v2&px=999 "5.jpg")

![condition1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323676iED30126FA206226C/image-size/large?v=v2&px=999 "condition1.jpg")

![6.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322548iDAA532F128BC863A/image-size/large?v=v2&px=999 "6.jpg")![7.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322550i38C815CD314347E5/image-size/large?v=v2&px=999 "7.jpg")

![condition2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323677iD72C1BCCB62951FF/image-size/large?v=v2&px=999 "condition2.jpg")

![8.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322549i86C7709566F830DA/image-size/large?v=v2&px=999 "8.jpg")

![subtask condition.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/323680i12AC643AF7F8A804/image-size/large?v=v2&px=999 "subtask condition.jpg")

![9.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322551i1E6FF64331883F7E/image-size/large?v=v2&px=999 "9.jpg")

comments: author: Bill Sheboy
body: Well, done! I have two suggested improvements to your rule:

1. Is it ever possible that an issue could transition from *To Do* to *In Progress* multiple times? If so, add a related issues condition earlier in the rule to ensure the subtasks do not already exist.
2. After each Send Web Request action, check the results with a condition before proceeding


author: Tim
body: Hi Bill,

thanks again for your great suggestions.  
Will take a look when I'm back at work and update my post with the final result.

Cheers,

Tim


author: Tim
body: Edited and updated the complete automation rule with checks as suggested from Bill. Thanks again for your help!


Tags: cloud

custom-field

group

jira

jira-cloud