Hi
I'm trying to create a scripted number field to calculate the number of days between a custom date field (deadline) and the current date, however, I'm getting a "No signature of method" error.
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.fields.ImmutableCustomField.minus() is applicable for argument types: (Date) values: [Fri Sep 09 17:51:34 MST 2022] Possible solutions: find(), find(groovy.lang.Closure), is(java.lang.Object), any(), use([Ljava.lang.Object;), print(java.lang.Object) at Script118.run(Script118.groovy:17)
When I ran the custom date field code in the console, like this:
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def deadline = customFieldManager.getCustomFieldObject("customfield_13201")
return deadline
it returned the custom field name "Deadline". However when I run the current date code:
def currentDate = new Date()
return currentDate
It returns the result "Fri Sep 09 18:05:26 MST 2022".
When checking one of the issues the Deadline custom date field value is displayed like this "10/Sep/22".
I think the error might be related to the date format. I don't know how to fix it. Can someone help me to fix the issue? Here is the code
import com.atlassian.jira.component.ComponentAccessor
import java.text.SimpleDateFormat
import org.apache.log4j.Logger
import java.util.Date
import com.atlassian.jira.issue.fields.ImmutableCustomField
import com.atlassian.jira.issue.fields.CustomField
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def deadline = customFieldManager.getCustomFieldObject("customfield_13201")
def currentDate = new Date()
if (deadline != null) {
def daysDiff = deadline - currentDate
return daysDiff
}
return null
Thank you for your help.