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

Changes not saved when transition validation is false

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

1 answer

0 votes

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?

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.

Suggest an answer

Log in or Sign up to answer
TAGS

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