[JMWE] adds a value to a field, from the subtask field to the parent field

RIZKY JTUASIKAL
Contributor
October 24, 2023

I have 1 Parent and 1 Subtask, here are the details:

Parent (Project):
Project has a field, named TOTAL BUDGET.

Subtask (PCRF) :
PCRF can be created repeatedly if there are changes from the budget side.

For example: PCRF 1, PCRF 2, PCRF 3 and so on.

**As long as the Parent status is not Completed.

And last, this subtask has a field, named APPROVED BUDGET.

 

 


I have the following example cases:

1. The user create the first PCRF subtask, with the value of the Approved Budget field is 100.

 

PCRF 1.

Approved Budget = 100

Then, after the PCRF status has been Completed, the value of 100 will be stored in the Parent task.
It will be stored in the Total Budget field.

Parent
Total Budget = 100

 

2. The user create a second PCRF subtask, with the value of the Approved Budget field is 50. 

 

PCRF 2.
Approved Budget = 50

Then, after the 2nd PCRF status becomes Completed, the value of 50 will be summed up with the value in the previous Total Budget field.
(50 +100)

So, the Total Budget field value will automatically become 150.

Parent
Total Budget = 150

 

 

The question is, how do we make processes 1 and 2 above run?

What post function do I need?

 

please help,
Thank you in advance.

1 answer

1 accepted

1 vote
Answer accepted
Neel Mohapatra _Appfire_
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.
October 25, 2023

Hi @RIZKY JTUASIKAL ,

To achieve the desired solution, you can create a  set issue field postfunction on the Complete transition.

then select "Parent of the current subtask" as shown in the below eg:
select the field that you want to update eg: "TOTAL BUDGET"

and then add the below code 

{{issue | parentIssue | field("fields.customfield_10055") + issue.fields["APPROVED BUDGET"]}}


file1.jpg

note: Please replace the customfieldId_10055 with the customfield id of field "TOTAL BUDGET" and in place of approved budget, please see the correct format, to get the correct format please see the example below.

tes1.jpg

Please let me know if it worked for you or if you have any questions.

Regards,
Neel

RIZKY JTUASIKAL
Contributor
October 25, 2023

Hi @Neel Mohapatra _Appfire_ ,

I've tried your suggestion, and it worked well.

I have one question,
what is the difference when selecting a field with "Name" or "ID"? is there any different functionality between the two?

Capture.PNG



And thanks for the help, I really appreciate it. :)

Neel Mohapatra _Appfire_
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.
October 26, 2023

Hi @RIZKY JTUASIKAL ,

Good to hear that you were able to get it working.

Regarding the diff between ID and Name, There could be two fields with the same name but they are distinguished by customfield id, even in future the field name is changed, the custom field ID remains same.

It is suggested to use the customfield ID instead of the name.

You can get the customfield ID by selecting the ID as shown in the below screenshot.t.jpg

Regards,
Neel

Like RIZKY JTUASIKAL likes this
RIZKY JTUASIKAL
Contributor
October 26, 2023

Hi @Neel Mohapatra _Appfire_ ,

 

thanks for explaining, now I understand the difference.

Thank you very much, Neel

 

regards

Suggest an answer

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

Atlassian Community Events