Howto get Smart Value for groupId from custom single groupPicker field

Tim May 7, 2024

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

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

 

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

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

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

 

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

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 7, 2024

Hi @Tim 

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

Tim May 7, 2024

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

auditLog.jpg

Best regards,

Tim

Like Bill Sheboy likes this
1 vote
Tim May 8, 2024

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

2.jpg3.jpg4.jpg5.jpg

condition1.jpg

6.jpg7.jpg

condition2.jpg

8.jpg

subtask condition.jpg

9.jpg

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2024

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
Like Tim likes this
Tim May 8, 2024

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

Like Bill Sheboy likes this
Tim May 14, 2024

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

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events