Error creating issue: Property 'newSubTask' not found?

I am creating a mutable issue 'newSubTask' in my groovy script and also setting it's properties, and this is a subtask of the issue on whose On Create transition I am writing this post function. I was using ScriptRunner 4.3.13 up until now, and recently used the SR version 3.0.16 with another JIRA instance and copied this project and ran it and rceived this error of Propertyu not found. Is it due to the older version of script runner? Or is it because I might have made an error in copying? I think it is the former, though. How do I eliminate this error? (Since this JIRA instance has a lot of other projects which are using SR older version, I wouldn't want to upgrade SR and cause a havoc).

17 answers

Dear Shagufta, ff you use script on different JIRA instances it mean that JIRA version also changed. Also changed version of JIRA API. 

Could you provide code and JIRA versions for both instances?

the JIRA version there is 6.4 and ScripRunner is 3.0.16.

The code is as follows:


if (valueOfRType == 'someVal') 
{ MutableIssue newSubTask = issueFactory.getIssue()     newSubTask.setAssigneeId(     
newSubTask.setFixVersions(Arrays.asList(versionn))newSubTask.setProjectObject(parentIssue.getProjectObject())     newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{it.getName() == "Sub-task"}.id)     
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>     
issueManager.createIssueObject(user, newIssueParams) 
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)    

This simple code works for JIRA 7.1.0 and ScriptRunner 4.3.13 . But now it is giving this error on the create issue screen itself, in the other version. (JIRA 6.4, SR 3.0.16)  @Vasiliy Zverev

I am not sure, but trouble could be here:

subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user)

Try to replace newSubtasc with value returned by issueManager.createIssueObject(user, newIssueParams)

Hi Shagufta,

Do you have anywhere in your script something like "Issue with summary ${newSubTask.summary} created"

There was a bug SRJIRA-544 which was fixed for the latest versions. If you cannot upgrade then a workaround is described in the issue above.

regards, Thanos

That line is commented in my code . So it isn't executing, hence doesnt make any difference, right? @Thanos Batagiannis [Adaptavist]

I afraid you have to remove it completely, even commented it will cause issues. 

Alternatively, to the workaround described in the linked bug above, you can also run the script from a file.

Oh! I'll remove it and see laugh

It worked!! Thanks! But the subtasks/other issues are not getting created. I mean, this issue is getting created but not any other issue programmatically. Is there some other syntax for creating issues in older versions? @Thanos Batagiannis [Adaptavist]?


So what you use is to create subtasks and if I understand right is working fine. And your question is how to create an issue (other than a subtask) for a JIRA v.6.* right ?

No. i create an issue by the normal procedure. and in the postfunction i create subtasks and issues automatically as in the code i have written above. but in this version of scriptrunner i am not being able to create those subtasks or issues through the same script. I click on create, fill the fields on create screen and press create. The issue is created. But the issues and subtasks which were supposed to be created automatically through the postfunction, are not created at all. so i am wondering if the syntax for creating subtasks programmatically in a groovy script was different for older versions. 

I think the reason is in the order of your post functions. You post function should be after the "Creates the issue originally." step. 

I suspect the answer will be in your logs. Feel free to paste here any errors you get in your logs.

It is after the step.

Also, there are no errors. I think in the older version of scriptrunner there isn't any way to view errors. Anyway the issue is created without any errors , but the issues i create programmatically in its postfunction aren't created.

So, you are saying, there's no difference in the syntax, and the problem is somethinf else ? okay, i'll check...

I just tested with a SR v3.1.4 the script below 

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

Issue parentIssue = issue
if (parentIssue.isSubTask())

def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
def summariesList = ["summary1",
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()

summariesList.each { subTaskSummary ->
    MutableIssue newSubTask = issueFactory.getIssue()
        it.getName() == "Sub-task"
    // Add any other fields you want for the newly created sub task

    Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
    issueManager.createIssueObject(user.directoryUser, newIssueParams)
    subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user.directoryUser)

PS. You can find your JIRA logs  - application server logs.


I use JIRA 6.4.7 and SR 3.1.3. For me following function works:

ApplicationUser loggedInApplicationUser = ComponentAccessor.getJiraAuthenticationContext().getUser()
IssueInputParameters issueInputParametersCreate = ComponentAccessor.issueService.newIssueInputParameters()
issueInputParametersCreate.setIssueTypeId(ComponentAccessor.issueTypeSchemeManager.getSubTaskIssueTypesForProject(taskIssue.projectObject).find{"Atomic SubTask"}.id)
IssueService.CreateValidationResult createValidationResult
createValidationResult = ComponentAccessor.issueService.validateSubTaskCreate(loggedInApplicationUser,, issueInputParametersCreate)
if (createValidationResult.isValid()) {
    IssueService.IssueResult createResult = ComponentAccessor.issueService.create(loggedInApplicationUser, createValidationResult)
    if (createResult.isValid()) {

        if (log.isDebugEnabled()) log.debug logPref + "New issue: " + createResult.issue
        ComponentAccessor.subTaskManager.createSubTaskIssueLink(taskIssue, createResult.issue, loggedInApplicationUser.directoryUser)
	} else {
        log.error "Error creating new Task Planning issue"
        for (String error : createResult.getErrorCollection().getErrors().values()) log.error error
} else {
    log.error "Error validating new Task Planning issue "
    for (String error : createValidationResult.getErrorCollection().getErrors().values()) log.error error

Yes this works. I'll modify my script to the older functions. Thanks a lot!!! One last thing, to assign the iissue to the current user, the line


Will this remain the same? Or is the setAssigneeId function expecting something else in the older versions?

@Thanos Batagiannis [Adaptavist]

Hi Shagufta,

cool. So it is 


regards, Thanos   

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,284 views 5 10
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you