Forums

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

Using Scriptrunner to set a custom date field by adding a custom number field to today's date

Matt Noe
Contributor
March 26, 2025 edited

I'm attempting to do some calculation on the fly to set an SLO date based on the date of the transition plus a custom number field value.  I think I'm close, but can't figure out what I need to improve.

Here is my console code I'm using to test:

 

 

def thisissue = Issues.getByKey("CLECOPS-7")
def dateplus = thisissue.getCustomFieldValue("Commitment SLO")as int
def today = new Date()
def slodateplus = today + dateplus

setCustomFieldValue("Vendor Processing SLO Date",new Date(slodateplus.getTime()))
And here is the result:

 

org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: Script_ca4bec07532a334a4674acf9a9009729.setCustomFieldValue() is applicable for argument types: (String, Date) values: [Vendor Processing SLO Date, Wed Apr 09 17:10:23 UTC 2025] at ConsoleScriptExecution1_groovyProxy.run(Unknown Source) Caused by: groovy.lang.MissingMethodException: No signature of method: Script_ca4bec07532a334a4674acf9a9009729.setCustomFieldValue() is applicable for argument types: (String, Date) values: [Vendor Processing SLO Date, Wed Apr 09 17:10:23 UTC 2025] at Script_ca4bec07532a334a4674acf9a9009729.run(Script_ca4bec07532a334a4674acf9a9009729.groovy:6) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:27) at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:41) at ConsoleScriptExecution1_groovyProxy.run(Unknown Source) at com.adaptavist.sr.cloud.MainHandler.executeScript(MainHandler.groovy:416) at com.adaptavist.sr.cloud.MainHandler.processInput(MainHandler.groovy:365) at com.adaptavist.sr.cloud.MainHandler.access$1(MainHandler.groovy) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure2.doCall(MainHandler.groovy:173) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure2.call(MainHandler.groovy)

 

I'm assuming that my issue is that my custom date field is for the date only and not the time, and that the function I'm using is giving date and time, which is causing the script to error.

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 26, 2025

Hi Matt,

From the log message I am going to assume you are trying to update the field using a Post-Function.

What is the value that you intend to increment Date field with? Is it by number of days, i.e. the number field will specify the number of days to add to the date field?

If you could provide the information above, I will provide a sample for your reference.

I am looking forward to your feedback and clarification.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events