I want to use the exact same code as in this ticket: https://community.atlassian.com/t5/Answers-Developer-Questions/Check-if-a-date-inserted-in-the-create-screen-is-compliant-to-my/qaq-p/469905
I want to add it in validators, I tried in both "Custom Script Validator" and "Simple scriped validator", but getFieldByName() in not recognized in the script.
How can this be solved? Thansk in advance
Hi @Maro Hamamjyan,
I suppose the script you mentioned is for Behaviour and some methods are vary from beviours to post-function/validator/listerner
hopefully below snippet will solve your getting custom field value
def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Custom Field Name")
def value = issue.getCustomFieldValue(cf) as Date
Thank you for the code. I want to check if my custom field named "End date" is less than today+30 days, the reporter should get validation error and should not be able to create the ticket. For that I used this (Attaching the screenshot), I know I must write the error message in the error message box, but how can I connect it with the condition?
you are almost there, "setError" method will work in behaviour but not in validator
Just place the message in Error field and "return false" in your script that will throw your error message in the screen
return true // will allow the transition
return false //will block the transition
hope it gives some idea
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