Forums

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

create multiple subtasks based on custom group field +SIL Script

Derek Imrie February 12, 2019

Hi,

I'm looking to try and add multiple sub tasks when I transition between two status

The idea is that the I have a custom group field where and sub tasks will be created for all the groups in the custom field.

For example , Group1, Group2, and Group3 are selected in custom field then, 3 approval sub tasks are created.

 

heres what I've got so far

//add comment
addComment(key, currentUser(), "Peer Review Approved");

// change approvers are here
string[] issue_approvers = customfield_10072;

// Create Change Approval Sub-tasks
string issue_project = Project;
string issue_parent_key = key;
string issue_type = "Approval";
string issue_summary = "Approval Task for " +issue_approvers ;
string issue_priority = "";
string issue_description = "Before Approving please ensure you happy with change documentation";
string[] issue_components;
date issue_dueDate = "";
string issue_security_level;
string[] issue_fields_mapping;


// loop for approver groups in custom field
for (string issue in issue_approvers) {
//ensure all fields added to task screen
string i = createIssue(issue_project, issue_parent_key, issue_type, issue_summary, issue_priority, issue_description,
issue_components, issue_dueDate, issue_security_level, issue_fields_mapping);
}

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 12, 2019

Hello,

Is it not working?

Derek Imrie February 12, 2019

no, It was working when just adding one task without the for loop.

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 12, 2019

Maybe the for loop is not executed?

Derek Imrie February 12, 2019

yes, so if i take the string issue_approver out and remove the for loop it will create one approval task

 

//add comment
addComment(key, currentUser(), "Peer Review Approved");

// change approvers are here
//string[] issue_approvers = customfield_10072;

// Create Change Approval Sub-tasks
string issue_project = Project;
string issue_parent_key = key;
string issue_type = "Approval";
string issue_summary = "Approval Task for " +key;
string issue_priority = "";
string issue_description = "Before Approving please ensure you happy with change documentation";
string[] issue_components;
date issue_dueDate = "";
string issue_security_level;
string[] issue_fields_mapping;


// loop for approver groups in custom field
//for (string issue in issue_approvers) {
//ensure all fields added to task screen
string i = createIssue(issue_project, issue_parent_key, issue_type, issue_summary, issue_priority, issue_description,
issue_components, issue_dueDate, issue_security_level, issue_fields_mapping);
//}

// add reviewer custom field as assignee on new task
//%i%.assignee = %issue_parent_key%.assignee;

 

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 12, 2019

That is why I think that the for loop is never executed. Are you sure that issue_approvers has a value?

Derek Imrie February 12, 2019

yes, I checked that.  The field is also added to the task just in case that had something to do with it.

Suggest an answer

Log in or Sign up to answer