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.
Does anyone know what could be the reason?
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.