I have custom field as named "WARRANTY DATE" (date picker) , i need to get this field value and have to compare with system's date.
If WARRANTY DATE is before than SYSTEM'S DATE it has to give not walid else valid.
plz help me
I am new to groovy
Hi,This code should work:
import com.atlassian.jira.component.ComponentAccessordef customFieldManager = ComponentAccessor.customFieldManagerdef warrantyField = customFieldManager.getCustomFieldObjectByName("WARRANTY DATE")def warranty = issue.getCustomFieldValue(warrantyField)def systemDate = new Date()return warranty > systemDate
In this code, you take warranty date and system date and the return statement compares it. If warranty is before systemDate, it returns false and if warranty is after systemDate it returns true.Regards,Marcos
i am getting error as static type checking The variable (issue) is undeclared.
I have tried with underlyingissue and MutableIssue library but didnt work
Hi,
Where are you running the script? Listener, Workflow, Console...?
Regards,
Marcos
console
Hi,Then you have to run this:
import com.atlassian.jira.component.ComponentAccessordef issueManager = ComponentAccessor.issueManagerdef customFieldManager = ComponentAccessor.customFieldManagerdef warrantyField = customFieldManager.getCustomFieldObjectByName("WARRANTY DATE")def issue = issueManager.getIssueByCurrentKey("DEMO-123")def warranty = issue.getCustomFieldValue(warrantyField)def systemDate = new Date()return warranty > systemDate
Replacing "DEMO-123" for the key of the issue you want to check.You can use the first version of the code when using a Listener or a Workflow script.Regards,Marcos
Thank you
I ll check
Getting error in return statement.
Cannot find matching method
Please, paste the full error.
Without the full error I can't know if it's a typo or a code error.
Thanks
java.lang.Object#compareTo(java.util.Date). Please check if the declared type is right and if the method exists.
Hi,Did you run the script?The error that you are reporting is the error that shows the red underlined >, right?
It's because, in script, warranty has no type defined, but in execution time it should work.I'd just tried the script that I sent to you and it worked perfectly to me.
Regards,Marcos
I am not getting output
Although it is showing no error in executions.
Please help me to sort out this
In this image is how should it look to you after clicking "Run" on Script Console.
The output is in the "Result" tab.
yaa fine..
But do you knw how to execute this in script field using date picker custom field
I have tried it is showing invalid date
I dont want to mention issue Key also. Ex(DEMO-123)
First version is fine but it has to show values valid or invalid when it compares.
It looks like you're new here. Sign in or register to get started.