So i created a Scriptrunner Behaviour to add some servor side validations on a custom field. It works fine someone is editing the field through UI. But at the same time when someone edits the field using the Jira REST API, the validations aren't applied.
Do i need to add something else to make it work? Please suggest.
Here is my code snap:
def fieldToHide = getFieldByName("abc")
def urgencia = getFieldByName("def")
def optionValue = urgencia.getValue().toString()
fieldToHide.setHidden(true)
if (optionValue == 'xxx') {
urgencia.setError("You cannot enter xxx")
}
else {
fieldToHide.setHidden(false)
}
No, because Behaviours are mostly done by adding scripts to the page so the browser does the work as it renders the page. REST renders nothing, there's nowhere to run the Behaviour.
Hey, Thanks for your prompt reply. Is there a way we can achieve the same behaviour for REST calls as well as it would be more consistent?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not for edit actions. Best you can do is put validators on transitions so issues cannot progress with invalid data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
True but validators are attached to certain Workflows right? My requirement is attach it to an Issue type. Is that possible?
For eg: i want to attach validations for few custom fields for an issue type 'ABC' whenever someone creates/edits.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot attach any validation to an issue type. You attach validation to a workflow. You attach Behaviours to screens (but REST has not got any).
You will need to put validators on the create transition for REST creates to be checked. Edit has no validation beyond what each field can do.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok that makes sense. So how do you suggest i approach this problem given that my issue type maybe be attached to multiple workflows and
1. whenever someone creates/edits an issue, i need to validate few custom fields and only if they are valid he/she should be able to submit the issue.
2. Also when someone edits the issue i want to enable few custom fields for edit based on a condition.
These two things should be applied irrespective of whether the user comes from UI or through REST API.
Again i would like to thank you for your prompt and to-the point replies which really helped me and saved my time. Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are not going to be able to validate Edit actions over REST, best you can do, as I said, is to prevent issues that have had invalid data set from progressing further through the workflow until corrected.
You can validate fields on create issue, add validators to the create transition.
There are no conditional edits in Jira, you can either edit a field or you can't, based on whether the field is on screen or not.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.