I have create a validation script in one transition.
I added a customfield update in the validation, so is something like this
if validation == true
{ MutableIssue mi = (MutableIssue) issue; mi.setCustomFieldValue(CampoAPPT, "En Progreso"); ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.ISSUE_UPDATED, false); return true }
else
{ MutableIssue mi = (MutableIssue) issue; mi.setCustomFieldValue(CampoAPPT, "No Agendado"); ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.ISSUE_UPDATED, false); return false }
If i execute this in the console, i get the customfield updated in both cases. But if i do the transition, false validation doesn't update the field
Validators should not update fields. A validator is for checking input, and the only thing they do is return a pass or a fail (with an error message, optionally)
Do not try to do this. Move the custom field update into a post function, after you know the person has entered something that is valid.
The reason why i'm using a Validator is that my script calls a REST API on another platform.
If the call goes OK, i do the transition.
But if the call fails, i would like to update a customfield and add a comment.
As far as i can see, when validation fails, the update doesn't run.
Is there a way to force the issue (mutable issue) to be saved?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The update can't run, you have not got to the point where you can write anything to the issue in a validator.
You will need to validate first, returning a pass or fail, and then do the update in a post function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.