Hi Team,
I am trying to add a scripted validator in workflow, to throw an error when customfield date is in future date (greater than current date).
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import groovy.time.TimeCategory
import java.util.Date
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import java.text.SimpleDateFormat
def cf1 = getFieldByName("Change Start Date / Time")
Date date = new Date()
Date DateVal1 = (cf1.value as Date)
//Date DateVal2 = (cf2.value as Date)
if (DateVal1.getTime() > date) {
cf1.setError("Change Start Date Cannot be in future while moving to implemented")
}else{
cf1.clearError()
}
I am getting the below error:
2021-03-23 16:50:33,355 ERROR [workflow.AbstractScriptWorkflowFunction]: Workflow script has failed on issue MDTCM-2384 for user . View here: <jiraURL>
groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getFieldByName() is applicable for argument types: (String) values: [Change Start Date / Time]
at Script80.run(Script80.groovy:12)
Can someone help me to debug the issue here
Regards,
Prashant