Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Sub-task is not getting created

Here is my Script with Jira version 8.11 and Script Runner Version 6.12

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

def project = ComponentAccessor.projectManager.getProjectByCurrentKey("HC")
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def parentIssue = ComponentAccessor.issueManager.getIssueByCurrentKey("HC-1");
MutableIssue issue = ComponentAccessor.issueFactory.issue
issue.projectObject = project
issue.summary = "This Is Sub-Task"
issue.issueTypeId = 10006
issue.setReporter(loggedInUser)
issue.setReporterId("dhandaresanjay@gmail.com")
issue.assignee = loggedInUser
ComponentAccessor.issueManager.createIssueObject(loggedInUser,issue)
ComponentAccessor.subTaskManager.createSubTaskIssueLink(parentIssue,issue,loggedInUser)

 

But getting this error

 

ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue HC-7 for user 'sanjay'. View here: http://localhost:8080/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=Software+Simplified+Workflow+for+Project+HC&descriptorTab=postfunctions&workflowTransition=1&highlight=4 java.lang.AssertionError: Errors: {reporter=The reporter specified is not a user.} Error Messages: []. Expression: validationResult.valid

 

 

1 answer

Hi @sanjay ,

If you are using the script runner add-on in your server instance, then in the post-function please do select the script runner in that we have an option called to create a sub-task. Once you select that option you may need to fill up a few options like subtasks issue type name, condition to create the subtask, fields to copy, etc to create a subtask in the transition. 

Please do check and let me know for any queries in it.

 

Cheers

Mone Dileep Kumar

Hi @Mone Dileep Kumar 

I need to create the Sub-Task based on condition like 

  • On the parent ticket creation form, there will be a field (quantity) which will accept numbers.
  • Depending on the number entered in the field, number of child tickets are to be created automatically.
  • For example if I enter 5 in the number field, right after I hit create button on parent ticket, 5 sub tasks should get created.
  • Child tickets should have field values same as parent tickets.
  • All child tickets should be unassigned

Thats why I need custom script post function

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

102 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you