Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update sub-task status based on another sub-task transition - SIL - Power Scripts

Derek Imrie February 11, 2019

Hi,

I have sub tasks set up as approval tasks, if some is the transition the sub task to rejected status I want to update all the other sub-task status to cancelled.

I'm still very new to SIL Scripting and JIRA in general.

Currently using cloud  JIRA

I have searched CPrime documentation and Atlassion community and can't see anything that is using something simiilar

 

Current code is bring back incompatible array error.  Any help much appreciated

//get all subtasks 

string s_tasks=subtasks(key);

for(string s in s_tasks){
//if subtask not rejected and not in resolution not done
if (%s%.status != "Rejected" || %s%.resolution != "Done")
return;
for(string s in subtasks(key)) {
%s%.status = "Cancelled";
}
}

}

 

1 answer

0 votes
Alexey Matveev
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.
February 11, 2019

Hello,

Your script should look like this:

string [] s_tasks=subtasks(key);

for(string s in s_tasks){
//if subtask not rejected and not in resolution not done
if (%s%.status != "Rejected" || %s%.resolution != "Done")
return;
for(string s in subtasks(key)) {
autotransition("Cancel", %s%);
}
}
Derek Imrie February 11, 2019

I was thinking about it a different way, don't think I would have got the update using transition rather than status directly.

Couple of questions, firstly is it always better to use the transition to update status or is there some instances where you would update the status directly?

Secondly, as as i am using cloud I need to use the transition id for autotranstion, do I need use the status id as well?

Derek Imrie February 11, 2019

So I've tried your code its not updating the other subtasks.  Added a comment so I know its firing 

 

addComment(key, currentUser(), "Approval Rejected");

string [] s_tasks=subtasks(key);

for(string s in s_tasks){
//if subtask not rejected and not in resolution not done - 10026 is rejected status
if (%s%.status != 10026 || %s%.resolution != "Done")
return;
for(string s in subtasks(key)) {
autotransition(21, %s%);
}
}

Alexey Matveev
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.
February 11, 2019

Kindly open a ticket in our service desk portal:

https://jira.cprime.io/servicedesk/customer/portal/2/user/login?destination=portal%2F2

The Service Desk will be able to see the logs from your Cloud Instance.

Suggest an answer

Log in or Sign up to answer