Forums

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

IF one Issue Type is Complete automatically another ticket should be Create with other IssueType

Kumar
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.
September 10, 2018

Hi,

I have an 2 Issue Types(unplanned and SI ) and Two workflows  for each issue type i have assigned each workflow. so, here is thing in Unplanned workflow I just created 2 transitions  (Contain & Re-Open ), Status(Containment and Complete).

So when I click on Contain transition it goes to  Complete Status after going to that stage I Want to create  automatically  an another ticket  With SI Issue type, and in the issue screen the costume fields like  (Linked Issue: relates to) and Link custom field : the unplanned ticket should be created before  and i have an word document Attachment custom Filed that word document should be assign automatically.

 

Is there any way to do like this???? if it is please let me know...

 

Thanks,

Phani    

1 answer

0 votes
Alex Christensen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 10, 2018

There's no way to do this out of the box. You should be able to do this using the Create/Clone issue post-function from the JMWE for Jira Server app.

I saw you tagged this with a ScriptRunner label, and this is totally possible to do using a scripted post-function. I don't have any code handy to share, but this or this might be a good starting place to help build a script for that. I'd recommend the first option I mentioned though - it's MUCH easier than trying to write a script for that.

Kumar
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.
September 11, 2018

Hi @Alex Christensen In Unplanned issue  workflow for "Contain transition" post-function i run a script its  createing the  new SI ticket . So after creating the new ticket in that  ticket  screen it ha to view automatically  which ticket it relates to.  The two costume field should be automatically view  (Linked issue: relates-to and Link: the Unplanned ticket ). can you please suggest me  those two custom fields automatically

iii.PNG

After Creating the SI ticket in that ticket this field should be   displayed automatically  as I shown in the photo

 

Here is the query that i have run in the post-function this will create only the ticket :

import com.atlassian.jira.component.ComponentAccessor

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

def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("JIR").id
summary = "Issue created from script"
issueTypeId = "1"
reporterId = user.name
}

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

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

 Thanks,

Phani

Alex Christensen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2018

You're definitely on the right track. I would also check out the createIssueLink() method under the IssueLinkManager class. You should be able to add some additional code at the end of your script once you create the issue to link from the current issue to the new one you just created.

Kumar
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.
September 11, 2018

Can you help me to add additional code in my script @Alex Christensen  if possible

Thanks,

Phani

Alex Christensen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 13, 2018

@Kumar, the code should look something like this. You'll need to change the link ID to whatever link type you want to use in your instance.

import com.atlassian.jira.component.ComponentAccessor

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

def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.with {
projectId = projectManager.getProjectObjByKey("JIR").id
summary = "Issue created from script"
issueTypeId = "1"
reporterId = user.name
}

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

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

// create issue link - change the "11010" to the link id
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
issueLinkManager.createIssueLink(issue.getId(), issueResult.getIssue().getId(), 11010, 1, user)
Kumar
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.
September 13, 2018

Hi @Alex Christensen Thanks You much for you response. And I have tried an new thing instead of running a query in post-function. 

For Contain Transition I have add post-function -->script postfunction-->Clone an issue and links-->In that Target project (I have selected that i'm working on) ---> Target Issue type( I have selected issue type what I want to create automatically) ---->Issue Link Type / Direction( I selected "Relates to") and the I add that post-function to that Contain transition.

Now, what exactly its doing means if "Contain" the ticket it will closed and there its self it will show you the new Ticket is created like this as shown below screenshort 

w.PNGthis new ticket  will automatically view on you screen when the ticked is closed.

and if you open the new ticket it will show you the closed ticket as shown below

e.PNG.

Suggest an answer

Log in or Sign up to answer