Forums

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

ScriptRunner Workflow Script Doesn't Run

Luis Hernandez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 29, 2023

Hello everyone,
I am looking for help hoping someone can support me.

I have 2 workflow scripts and one of them is not running. The first script does a project creation with shared settings and the second one via API creates a project in the BigPicture addon.

When the transition is executed the first script is executed and the second one is not, keeping the message that the script has not run yet.

hasNotRunYet.png

Does anyone know what could be the reason?

1 answer

1 accepted

1 vote
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 29, 2023

Hi @Luis Hernandez

Could you please share the code you use for the Custom Script Post-Function so I can review it and provide some feedback?

Also, please share the versions of Jira, ScriptRunner and BigPicture that you are currently using. I am requesting this to configure my environment to match yours and try to provide a better solution.

Thank you and Kind regards,

Ram

Luis Hernandez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 30, 2023

Hello @Ram Kumar Aravindakshan _Adaptavist_,

Thanks for your support. I managed to identify the error because it is not running the code to see if you can help me how I can handle the errors. I am getting the value of a customfield but when it is empty it returns a null, how can I prevent the script from failing when this scenario happens?

 

def boxTypeId = "8"
def projectName = newFinalProjectName
def cfStartDate = customFieldManager.getCustomFieldObject('customfield_14304')
def cfEndDate = customFieldManager.getCustomFieldObject('customfield_14305')

// startDate and endDate returns null and the script fail
def dateStart = currentIssue.getCustomFieldValue(cfStartDate) as Date 
def dateEnd = currentIssue.getCustomFieldValue(cfEndDate) as Date

Cheers

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
May 30, 2023

Hi @Luis Hernandez

Looking at the code snipped that you have shared, I didn't find any form of validation to verify if the Date fields were not null.

Also, when setting the value for the date field, the default format it is set to is String.

You should try adding a validation like:-

def dateStart = currentIssue.getCustomFieldValue(cfStartDate)
def endDate = currentIssue.getCustomFieldValue(cfEndDate)

if(dateStart
.toString()!='null' && endDate.toString()!='null') {
def dateStartValue = dateStart as Date
def endDateValue = endDate as Date

// Your code
}

I hope this helps to answer your question. :-)

Thank you and Kind regards,
Ram

Like Luis Hernandez likes this

Suggest an answer

Log in or Sign up to answer