Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

End postfunction scriptrunner script if a condition is met.

I was wondering if there is a way to end a postfunction script if a condition is met. In the case below if  if (input1 == 'NOT APPLICABLE') i need it to end this script and continue on with the other postfunctions in my create transition.  Currently if i use the value 'NOT APPLICABLE' the script errors out and the other post functions do not process. 


// get custom fields
def customFields = get("/rest/api/2/field")
.findAll { (it as Map).custom } as List<Map>

def fields = issue.fields as Map"${fields}")
def projectKey = issue.fields.project.key"${projectKey}")
def inputprojecttype = customFields.find { == 'PIA Project' }?.id"${inputprojecttype}")
def subjectident = customFields.find { == 'Subject' }?.id"${subjectident}")
def project = fields.project as Map"${project}")
def input1 = issue.fields[inputprojecttype].value as String"${input1}")
def subjectval = fields[subjectident] as String"${subjectval}")
def queuedissueparent


if (input1 != 'NOT APPLICABLE'){
if (input1 == 'Rapid Design Engagement'){
queuedissueparent = 'BPIA-1132'

if (input1 == 'Fixed Wireless') {
queuedissueparent = 'BPIA-1133'

if (input1 == 'Head End') {
queuedissueparent = 'BPIA-1134'

if (input1 == 'Conduit Design') {
queuedissueparent = 'BPIA-1135'

if (input1 == 'Subdivision GIS Design') {
queuedissueparent = 'BPIA-1136'

if (input1 == 'Business Readiness') {
queuedissueparent = 'BPIA-1137'

if (input1 == 'OSP') {
queuedissueparent = 'BPIA-1138'

if (input1 == 'Confluence Space Standardization') {
queuedissueparent = 'BPIA-1139'

if (input1 == 'Contracts') {
queuedissueparent = 'BPIA-1140'

if (input1 == 'Change Orders') {
queuedissueparent = 'BPIA-1141'

if (input1 == 'Department User Dashboards') {
queuedissueparent = 'BPIA-1142'

if (input1 == 'Departmental Dashboards') {
queuedissueparent = 'BPIA-839'

if (input1 == 'EPP') {
queuedissueparent = 'BPIA-1143'

if (input1 == 'Feasibility') {
queuedissueparent = 'BPIA-368'

if (input1 == 'Member Dashboards') {
queuedissueparent = 'BPIA-1145'

if (input1 == 'Member Project Information Updates') {
queuedissueparent = 'BPIA-1161'

if (input1 == 'Regional Dashboards') {
queuedissueparent = 'BPIA-1146'

if (input1 == 'Revamp the PIA Request Process') {
queuedissueparent = 'BPIA-1147'

if (input1 == 'IMS Training Process Documentation') {
queuedissueparent = 'BPIA-1144'

if (input1 == 'IMS Member Rollout') {
queuedissueparent = 'BPIA-197'

// fetch issue objects from key (queuedissueparent)
def issueResp = get("/rest/api/2/issue/${queuedissueparent}")
assert issueResp.status == 200

def issue = issueResp.body as Map

def typeResp = get('/rest/api/2/issuetype')
assert typeResp.status == 200
def issueTypes = typeResp.body as List<Map>

def issueType = "PIA Request Subtask" // The Sub Task Issue Type to Use

// Get the sub task issue type to use
def issueTypeId = issueTypes.find { it.subtask && == issueType }?.id"${issueTypeId}")
assert issueTypeId : "No subtasks issue type found called '${issueType}'"

// Get the project to create the subtask in
// Create the subtask
def resp = post("/rest/api/2/issue")
.header("Content-Type", "application/json")
fields: [
project: project,
issuetype: [
id: issueTypeId
parent: [
"key" : "${queuedissueparent}"],
summary: subjectval

// Get and validate the newly created subtask
def subtask = resp.body
assert resp.status >= 200 && resp.status < 300 && subtask && subtask.key != null

// If the sub task created successfully return a success message along with its key
if (resp.status == 201) {
return 'Success - Sub Task Created with the key of ' + resp.body.key.toString()
} else {
return "${resp.status}: ${resp.body}"

1 answer

1 accepted

1 vote
Answer accepted

I don't use the cloud, but I assume that this should work (near the top)

if (input1 == 'NOT APPLICABLE') {

I can't believe it was that simple. I think I was using return; without the value brackets and that's why everything was erroring out. Thank you for your help!

Like johnson reddy likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

ThinkTilt is joining the Atlassian Family!

This morning, Atlassian announced the acquisition of ThinkTilt , the maker of ProForma, a no-code/low code form builder with 700+ customers worldwide. ThinkTilt helps IT empower any team in their or...

354 views 19 20
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