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

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 Champion Sep 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.

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 Champion Sep 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.

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

Thanks,

Phani

Alex Christensen Community Champion Sep 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)

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
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

1,311 views 17 10
Join discussion

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