Forums

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

scriptrunner for creating scheduled issues

SaidAslan
Contributor
July 4, 2016

hi there.

have a ScriptRunner v.4.3.4 and JIRA 7.1.0. the task is to create a scheduled issues, one per week via Services. 

I tried the code below,

import com.atlassian.jira.component.ComponentAccessor

def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def constantsManager = ComponentAccessor.getConstantsManager()
def issueType = constantsManager.getAllIssueTypeObjects().find {it.name.equalsIgnoreCase("Incident")}
def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.with {
    projectId = projectManager.getProjectObjByKey("SD").id
    summary = "Scheduled Issue"
    issueTypeId = issueType.getId()
    reporterId = "admin"
}

def validationResult = issueService.validateCreate(user, issueInputParameters)
assert !validationResult.errorCollection.hasAnyErrors()

def issueResult = issueService.create(user, validationResult)
log.info "Issue created: ${issueResult.issue}"
return "Issue created: ${issueResult.issue}"

but if paste it in Script Console, the result is 

Issue created: null

can anyone explain me how to make it work? 

1 answer

0 votes
Marlon Grawer
July 28, 2015

Hello Keven,

I believe the best way you can do this is by adding AllWatchers permission in the browse permissions and in the comment permissions as well. Thus your issues will be visible not only for those who created them, but also for those you @mention in the issue, once they become watchers of an issue at the moment you mention them in it.

 

Hope this helps.

Regards,

Marlon.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events