Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Error while comparing date custom field with current date

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 'HK31'. View here: https://jira.dev.global.tesco.org/secure/admin/workflows/ViewWorkflowTransition.jspa?workflowMode=live&workflowName=Tesco+Change+Management+Workflow+20112019&descriptorTab=validators&workflowStep=4&workflowTransition=31&highlight=8
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

 

 

1 answer

I am able to achieve the solution for the above query with a JQL validator.

 

However, we don't want the validator any more, but a pop-up message (warning) need to appear whenever the Custom Date field is greater than the current date during the transition.

Can we achieve this?

 

Regards,

Prashant

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.2
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

130 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you