Create Sub Tasks based Multi Select Custom Field

Govardan Krishna May 29, 2013

Hi,

In create issue Screen, i have a multi select custom field, which has below options

Options: Reviewer 1, Reviewer 2, Reviewer 3, Reviewer 4 ...

User can be able to choose/tick as many options he wanted,

like if user selected/tick: Reviewer 1, Reviewer 4 - then i need to create sub tasks and assign it to selected Users from Multi select custome field

Sub Task 1:

1. Assign to Reviewer 1

2. Copy Summary from Parent Issue

Sub Task 2:

1. Assign to Reviewer 4

2. Copy Summary from Parent Issue

Your help is appreciated

5 answers

0 votes
siva December 6, 2018

Hi,

In create issue Screen, i have a multi select custom field, which has below options

Options: finance , construction, banking , electrical.

User can be able to choose/tick as many options he wanted,

like if user selected/tick: finance and construction - then i need to create sub tasks  from Multi select custom field.

Sub Task 1:

 

Sub Task 2:

 

( do you have a script for this)

0 votes
Govardan Krishna May 30, 2013

I was able to achieve this with below code, in case any one needed

cfStewards = customFieldManager.getCustomFieldObjectByName("Stewards")

Collection<User> users= (Collection) issue.getCustomFieldValue(cfStewards);

if(users != null)
{
for(i in 0..users.size()-1)
{
Object AssigneeValue = users.get(i).getName();

issueObject = issueFactory.getIssue()
issueObject.setProject(issue.getProject())
issueObject.setIssueTypeId("10")
issueObject.setParentId(issue.getId())

issueObject.setSummary(issue.getSummary())
issueObject.setAssigneeId(AssigneeValue)

subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject)
subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser())
i++
}

}

Kathleen Jacobs June 4, 2013

Do you add this to the post function after you have the field filled in with the users?

is "Stewards" the name of your field?

Anything else I would need to set to customize it for my setup?

Govardan Krishna June 9, 2013

Yes, you have to add it to the post funtion, this will run after you filled in users.

In order to work for you, you need to set correct sub task issue type id..

issueObject.setIssueTypeId("10") --- check this ID in your database for correct sub task issue type id

mallikarjuna sankati January 29, 2015

Hi, In create issue Screen, i have a multi select custom field, which has below options Options: Reviewer 1, Reviewer 2, Reviewer 3, Reviewer 4 ... User can be able to choose/tick as many options he wanted, like if user selected/tick: Reviewer 1, Reviewer 4 - then i need to create sub tasks and assign it to selected Users from Multi select custome field Sub Task 1: 1. Assign to Reviewer 1 2. Copy Summary from Parent Issue Sub Task 2: 1. Assign to Reviewer 4 2. Copy Summary from Parent Issue Your help is appreciated

mallikarjuna sankati January 29, 2015

is it work for above requirement

mallikarjuna sankati January 29, 2015

I have a number field. based number I want create subtask. if I enter 5 then I want to create 5 subtasks. if I enter 10 then I want to create 5 subtasks Please help me on same

Srilatha Pokala February 2, 2015

Hi Mallikarjuna, Have you created Number field? If Yes, you can loop thru your custom number field and create subtasks based on number selected you should be able to use above code have you tried with above example?

mallikarjuna sankati February 3, 2015

yes I created number field and tried above code. but not working above code can I write this code in postfunction or listener? what listener can I use? for ex Create a subtask or fast track transition.....

mallikarjuna sankati February 3, 2015

any one can help me on above requirement

mallikarjuna sankati February 3, 2015

Hi Govardhan can u give me the Import class for above code .

Govardan Krishna February 4, 2015

Here are the imports i have used import com.atlassian.jira.issue.Issue import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.workflow.WorkflowTransitionUtil; import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl; import com.atlassian.jira.util.JiraUtils; import java.lang.Boolean; whats the error you are getting? when you say not working.. whats your issue?

mallikarjuna sankati February 5, 2015

r u woking above code on fasttrack transition? or any other post function. how can i test my code is working or not i am new to jira scripting

mallikarjuna sankati February 5, 2015

below is my coding import com.atlassian.jira.issue.Issue import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.workflow.WorkflowTransitionUtil; import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl; import com.atlassian.jira.util.JiraUtils; import java.lang.Boolean; cfLic = customFieldManager.getCustomFieldObjectByName("Number of Licenses") Collection<User> users= (Collection) issue.getCustomFieldValue(cfLic); if(users != null) { for(i in 0..users.size()-1) { Object AssigneeValue = users.get(i).getName(); issueObject = issueFactory.getIssue() issueObject.setProject(issue.getProject()) issueObject.setIssueTypeId("10417") issueObject.setParentId(issue.getId()) issueObject.setSummary(issue.getSummary()) issueObject.setAssigneeId(AssigneeValue) subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject) subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser()) i++ } }

mallikarjuna sankati February 5, 2015

my subtask issue type id is :10417

mallikarjuna sankati February 12, 2015

hi govardhan please help me on same

0 votes
Govardan Krishna May 29, 2013

Yes i am using Multi User Picker field

0 votes
Bhushan Nagaraj
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.
May 29, 2013

Are you using a multi-user select field?

0 votes
Bhushan Nagaraj
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.
May 29, 2013

You can use Jamie Echlin's script runner plugin. You might find the example code here helpful

https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions#PostFunctions-Cloneissuewithdependencylink

Govardan Krishna May 29, 2013

Thanks for the response Bhushan, script in the link you provided is to create sub tasks and copy parent values to subtasks which i did already, but now i want to read/get selected values from multi select custom field and set sub tasks assignee based on it

Raju Adluru March 31, 2015

Hi Govardan and Bhushan I have a similar requirement, when a custom field is set to 'Yes', need to create a subtask and assign to a user id I modified below script like this, and i am getting error msg, can you pls help with this. {code} cfDocReqd = customFieldManager.getCustomFieldObjectByName("Is Documentation (TD) Required?") cfvalue = issue.getCustomFieldValue(cfDocReqd); if (cfvalue= "Yes") { issueObject = issueFactory.getIssue() issueObject.setProject(issue.getProject()) issueObject.setIssueTypeId("10538") issueObject.setParentId(issue.getId()) issueObject.setSummary(issue.getSummary()) subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject) subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser()) } {code} Error i am getting : Script function failed on issue: : 101, file: <inline script> groovy.lang.MissingPropertyException: No such property: customFieldManager for class: Script8 at Script8.run(Script8.groovy:1) I am using this as post function to test this, once this is good, i want to use this as custom listener.

Suggest an answer

Log in or Sign up to answer