Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,882
Community Members
 
Community Events
176
Community Groups

Jira Automation: JSON & how to use parent issue custom field as assignee for sub task

Hi! 

I am trying to use JIRA Automation to create sub tasks in a parent issue, as a part of onboarding. This means the parent issue will be created by somebody, and a custom field - Manager - where the JIRA user responsible for the new employee will be selected. 

So, I can create the sub task when the parent issue is transitioned, but I am struggling to set the Manager as an assignee for the sub task. 

 

I am trying to add this as a JSON script under More options / Additional fieldsat the bottom of the Sub Task feature, but the rule fails to add assignee. I have tried with various variations of triggerissue, parentissue, .key, .accountId and so on. 

{
"fields": {
"assignee": { "id": "{{triggerissue.customfield.10091.accountId}}" }
}
}

Any help is greatly appreciated. Thanks! 

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @Bård Karstensen 

I notice there is a typo in your JSON expression:

{{triggerissue.customfield.10091.accountId}} should be 
{{triggerissue.customfield_10091.accountId}}

Kind regards,
Bill

Thank you @Bill Sheboy 

This solved the problem for me. 

Like Bill Sheboy likes this

@Bill Sheboy 

Hi! I'm looking to do something similar but can't get this solution to work for me. I have issue type "Article" with a custom people field for "Manager" (custom field ID 11134). When creating an issue of this type, I will fill the Manager field in with either "Aaron" or "Bobby".

I want to automatically assign the "Approve" task to Manager each time it is created, depending on who the Manager is, either Aaron or Bobby.

Here are a few things I have tried:

With these, the Approve subtask is created, but the Manager (Aaron or Bobby) is not added as the assignee (blank assignee field) —

Screen Shot 2022-10-12 at 5.39.35 PM.pngScreen Shot 2022-10-12 at 5.39.49 PM.png

With this, the Approve subtask is not created and it runs with an error —

Screen Shot 2022-10-12 at 5.41.38 PM.pngScreen Shot 2022-10-12 at 5.46.08 PM.png

If you could advise, I would appreciate it so much! Thanks! 

Hi @Emma Hecht 

First thing, you seem to be trying to set the assignee in two places, with the field and in the advanced edit with JSON.  Try clearing out the advanced edit.

Next, would you please post images of your complete rule and the audit log showing details of a rule run?  Those may provide context for what is happening.  Thanks!

And just to confirm, is this for a team-managed (TMP) or a company-managed project (CMP)?  I am guessing TMP as you note have a People field type.

Kind regards,
Bill

@Bill Sheboy Hi! Thanks so much for your response!

On the Assignee field and Additional fields — I ran each of those tests separately (so if I had something in the Assignee field, I didn't have any JSON in the Additional fields and vice versa)

Images of the rule —

Screen Shot 2022-10-13 at 9.15.56 AM.pngScreen Shot 2022-10-13 at 9.17.58 AM.png

 

Audit log (the whole log is configuration change > some errors, with some errors always being this same JSON message) —

Screen Shot 2022-10-13 at 9.24.47 AM.png

 

Last, yes this is a team managed project, which allows me to create the custom person fields like below for issues —

Screen Shot 2022-10-13 at 9.28.10 AM.png

This is curious...I tried your scenario and it worked for me...

  • I added a single-select People field to a team-managed project
  • triggered the rule from an issue
  • added an action to create a subtask for the trigger issue
  • and tried to set the assignee from the field, using both the field name and custom field id, with the accountId
  • both worked for me

 

Rules sometimes get "glitched" when adding/removing the advanced edit with JSON stuff.  Let's try this: disable this rule, and recreate it from scratch and retest.

Like Emma Hecht likes this

That worked! Thank you SO much!

Like Bill Sheboy likes this

@Bill Sheboy 

Follow-up question — should the custom field smart key work for sending emails? I'm trying to use it in the "to" field for an email notification, but I'm getting an error:

To field:

Screen Shot 2022-10-13 at 2.09.14 PM.pngIssue path:

Screen Shot 2022-10-13 at 2.09.48 PM.png

Audit log:

Screen Shot 2022-10-13 at 2.10.01 PM.png

Sadly, not yet...For some reason the People-type field's design in team-managed projects does not support the user attributes like email address.

Here is the suggestion to add that information, which you may watch/vote for to see progress: https://jira.atlassian.com/browse/JSWCLOUD-22200

The work-around depend on usage...

  • for a fixed value, hardcode in the email address
  • if you are setting the assignee based on a People-type field, try a Re-fetch action after the assignment and then try to use the assignee's email address instead
  • brute force approach: using the display name from the People-type field, call the REST API to get the user's information and use that to send the email.  This will add a few seconds to each rule execution.
Like Emma Hecht likes this

@Bill Sheboy 

Interested in learning how to implement the REST API solution! (So sorry, I don't have a strong background in coding or Jira). Can't find much on how to do this in Jira Is there an article I'm missing or would you be able to post a screenshot or the code?

Context: When I'm moving a certain subtask from "upcoming" to "done" I want to send an email to another user (not the assignee or one of the Jira-defined person fields, like reporter).

Thank you!

@Bill Sheboy 

Actually, figured out a simple workaround! Thanks so much for your help here! :) 

Screen Shot 2022-10-14 at 3.28.17 PM.png

Like Bill Sheboy likes this

Well done!

For future reference if you need to call the REST API for things automation rules do not support directly, please see this how-to article:

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

With your use case of getting the email address from the account Id, the method to call would be this:

yourJiraUrl/rest/api/2/user?accountId=theDesiredUserAccountId

Like Emma Hecht likes this
0 votes
Trudy Claspill Community Leader Dec 03, 2021

Refer to the image below.

In field #1 choose Assignee.

In field #2 choose Copy From Parent.

Screen Shot 2021-12-03 at 7.52.06 AM.png

Thank you @Trudy Claspill 
This could have been a solution, but in this particular case the assignee for the sub tasks would not always be the same as assignee for the parent issue. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events