Copy the fields values into another field

Lusine April 5, 2024

Hi everyone,

I have the following problem:

I am dealing with an issue type that involves subtasks, and I need to copy the value of a specific field from each subtask and consolidate them into one field in the main task.

The fields represent users from our company and offer multiple choices.

For example:

Subtask 1 - Field value: user1, user2, user3

Subtask 2 - Field value: user4, user5

Subtask 3 - Field value: user6, user7, user8, user9

Main task - Field value: user1, user2, user3, user4, user5, user6, user7, user8, user9

3 answers

1 accepted

1 vote
Answer accepted
Kalyan Sattaluri
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.
April 5, 2024

Hello @Lusine 

  • What kind of field is this? Multi Checkbox field?
  • What is the trigger for your rule?
    • Field change on sub-task?
    • Scheduled Trigger to do this sync every day irrespective of if Sub-tasks had any changes?
  • You tagged it as DC, do you have lookupIssues action available in Automation?
Lusine April 5, 2024

Hi @Kalyan Sattaluri ,

Thanks for responding.

  1. It's a field where I can select multiple users.
  2. I need this automation to trigger when the statuses of the subtasks are changed to "done".
  3. The field will remain unchanged after the automation.
  4. This action will be performed only once for each main task.

I require several employees to provide the names of the users from their respective directorates.

It will help a lot if you could help.

Kalyan Sattaluri
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.
April 5, 2024

Thanks for your response. Few more questions.

  • I understand your overall ask, that is, Main Task should have all values from sub-task, but, If a sub-task is transitioned to Done, do you want just that sub-task's value sync'd over to the parent, or, every time a sub-task is transitioned, we sync values from *all* sub-tasks even if they are not done? There is a difference between the 2 I mentioned above. Nothing complicated, but just want to clarify.
  • Please share what is this field called exactly in the sub-task issue. Share a screenshot of the field because we need to know the exact field value for this to work.
  • Please confirm that the story issue also has the same field, field name, field values.
  • Please clarify if you have lookupIssues action available?

Just FYI for future steps- we may need to know the customfield value of this field if referencing the field name does not work. But we will get there that comes.

Lusine April 5, 2024

No problem, Thanks for your help.

  1. I don't need the transition to occur each time one of the subtasks is completed. It should only activate when all the subtasks are done.
  2. The attached screenshot displays the field in question.
  3. Yes, the main task also possesses the same field where I intend to transfer the values from the subtasks.
  4. Please tell me how can I look if I have that action or not

 Screenshot 2024-04-05 172412.jpg

Kalyan Sattaluri
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.
April 5, 2024

OK, Please see below screenshot. In your automation, in any rule, after your trigger step, you get an option to choose action, if condition etc. Choose action and once in, check to see if you have lookup Issues action available.

Since you tagged this as Data center, your company needs to be on latest version since this functionality was released recently. So please confirm if you have below option..

image.png

Lusine April 5, 2024

No, our company's version is not the latest one.

Perhaps there is a plugin that I can use?

I have an issue type where the subtask comments are transitioned to the main task. However, in this instance, I need it to be a list of users and to avoid any overlap.

 

Kalyan Sattaluri
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.
April 5, 2024

Hmm. So we need to check if all sub-tasks are done or not, for that, if lookupIssues is not available, let me check if we can do this using smart values... if thats not possible, another option is to send a web request to gather this info.

So give me some time to check if its possible to implement this rule simply. 

----------------------------

In the mean time, can you check if you have access to create token.

Can you go to your Jira settings, by clicking your icon on top right, click profile, on the next page, select personal access token tab and see if you see an option to create a PAT on top right. Please see below link on same steps.

https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html 

If you can get this token, then this is our back up, may involve some new steps you havent done but will get the job done. Let me know if you can create Token.. While I check if we can get it done in a simple way.

------------------------

Thanks.

Kalyan Sattaluri
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.
April 5, 2024

@Lusine 

I think we can do this without web request step.

  • Create new rule with trigger = issue transitioned, and choose Done as status
  • Next do an if condition and check if Issue Type = sub-task
  • Then, do a log action and log 
    • {{issue.parent.subtasks.Stakeholders List.displayName}}
  • Then do another if condition, smart value check, and put: 
    • {{#issue.parent.subtasks}}{{#if(not(equals(status.name,"Done")))}}true{{/}}{{/}}     
    • DOES NOT CONTAIN 
    • true
  • Then do a branch -> For Parent
  • Inside it, log 
    • {{issue.parent.subtasks.Stakeholders List.displayName}} 

See below screenshot.

We are not updating the Parent issue yet. We are making sure logic works.

After setting up the rule, trigger it by taking an issue which has 2 subtasks. Transition both 2 done. Share with me the latest Audit log (see yellow highlighted section) along with the rule. I need both screens to understand progress.

If above logic works, we will update the parent. Let me know if any questions.

image.png

Lusine April 8, 2024

 @Kalyan Sattaluri 

Thanks a lot for your help.
I did as you said. Here is the screenshot.
This part is a success, what should I do for the part of the main task?image.png

Kalyan Sattaluri
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.
April 8, 2024

Hello @Lusine 

As you can see, the last log statement did not print so we need to correct it.

Can you use below smart value to log instead of earlier one and share screenshot of audit log once again.

{{triggerissue.parent.subtasks.Participants.displayName}}

Also, because you dont have "variable" option of newer Jira, we need to temporarily store participants info in a field before we can update Parent field..

Do you have a "Text" field in your parent which you dont use? Because we will overwrite whatever is in that field with our list and remove it when we are done with updating participants list.

So please take a look at your Parent issue and see if there is any such field we can use. If so, please share the field name and I will share rest of the rule.

Lusine April 8, 2024

@Kalyan Sattaluri

Now, log action is a success, it stores data.

image (1).png

Kalyan Sattaluri
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.
April 8, 2024

@Lusine 

Do you have a text field in your parent which you dont use? We need to store this info temporarily before we update the Participants list..

Can you take a look at your issue fields and let me know a field name we can use. If you are not sure, we have an alternative.. but this will be the easiest..

 

Lusine April 8, 2024

@Kalyan Sattaluri 

Yes, I have a "Description" field. It is a multiline text field.

But I'm going to open other subtasks for the users that are transferred. Can I do it from that multiline text field? 

Kalyan Sattaluri
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.
April 8, 2024

No, Description is a common field which honestly I dont want to use.

See if you have any other custom fields which are text type when you go into edit..

If not, we will store this list in issue's entity.. So we have a backup if you dont have one.

Lusine April 8, 2024

@Kalyan Sattaluri 
It is not a problem, I can add a field.

Lusine April 9, 2024

Hi @Kalyan Sattaluri ,

I'm sorry for taking so much time from you. But I feel like we're almost done.

This far everything is working what should I do next?

Kalyan Sattaluri
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.
April 9, 2024

Hello @Lusine 

I thought you were going to give me a name for the field we can use.

Lets assume, "Text 1" is this field and I will give you the steps.

After your branch,

  • For do a log statement and log below value so we can see output:

{{#triggerissue.parent.subtasks}}{{Participants.name}}{{^last}}, {{/}}{{/}}

  • Then you need to "edit Issue" and choose "Text 1" as field from drop down,  and assign it this value from above:

{{#triggerissue.parent.subtasks}}{{Participants.name}}{{^last}}, {{/}}{{/}}

  • Because we have just updated the issue, we need to wait some time, so we do action - Re Fectch Issue.
  • Now is when we update the issue. We choose Edit issue again. This time, instead of choosing a field drop down, we go to advanced edit section, delete everything which is there and replace it it with below JSON.

{ "fields": { "Participants": [ {{#Text 1.split(",")}}{"name" : "{{.}}" }{{^last}}, {{/}}{{/}} ] } }

Above step updates the field so we are good, we need to clean up the Text 1 field, so we choose edit issue once again  choose Text 1 from drop down and in the value to assign, give it {{clear}}. That will wipe the value we assigned earlier.

 

Please see screenshots below for reference.

Please make sure you log values as I have and shar3e your audit log if issues.

Please update your "Title" of this post to -- "Update Parent issue with Sub-Task values without lookupIssues}} so its relevant and helpful for others in the future when researching.

Please accept answer once its working so its beneficial for folks in future.

Thanks!

 

Screenshots for reference from Branch onwards.

image.png

image.png

image.png

Like Lusine likes this
tatevikalaverdyan April 9, 2024

@Kalyan Sattaluri It worked thank you very much !!!

Like Kalyan Sattaluri likes this
Lusine April 9, 2024

Hi @Kalyan Sattaluri ,

It worked thank you so much!!!

Like Kalyan Sattaluri likes this
0 votes
Lusine April 8, 2024

 

 

 

0 votes
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.
April 5, 2024

Hi @Lusine 

First thing, I am using Jira Cloud, not Jira Data Center, and so cannot test the suggestions I offer.  They are based on what I know about automation rules, in general.  With that out of the way...

I believe there may be two ways to solve this.  Let's check the easiest one first:

 

Issues have the subtasks smart value: {{issue.subtasks}} However, that may not include all of the data for each subtask, such as your user field.  The way to check that is using this how-to article, looking at an example issue with subtasks which have the user field set, and observe what you see.

https://confluence.atlassian.com/automation/find-the-smart-value-for-a-field-993924665.html

If you see the data for the users, the rule could use an iterator and advanced edit with JSON to add the users to the parent issue.

 

If the users were not visible for the subtasks, you can use the REST API to perform an issue search to load the subtask, and then use the same iterator and advanced edit technique on the results.

FYI, with Data Center, rules also have the Lookup Issues action, but I do not believe that has custom fields yet and so it will not help this scenario.

 

Kind regards,
Bill

Lusine April 8, 2024

Hi @Bill Sheboy ,

Thank you for your reply. I'm trying the way suggested below. But thanks a lot for your support.

Best regards,

Lusine

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer