Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Script Validator: update a priority to something other than the original, transition issue

Megan D February 22, 2024

Hello, 

I have 4 priorities set up:

  • Rush Job
  • 1-4
  • 5-6
  • 7

If the creator picks Rush Job, it needs Lead approval. If the Lead rejects the job as being a Rush, the creator needs to go back and EDIT the priority (by clicking the pencil icon on the issue) to one of the other three priorities. They would then click a button called "Fixed Priority" to transition the issue. Clicking the button without changing the priority would give a warning with a message.

Currently, the code only works if they change it to 1-4, but not any of the others; it returns a warning.

My current code in the Post-Function validator (Simple Script Validator) is:

if (issue.priority?.name == '1-4' || issue.priority?.name == '5-6' || issue.priority?.name == '7') {
issue.priority!= originalIssue.priority
}

Can anyone tell me what I'm doing wrong or have correct code/advice? Thank you! 


The final working code (checks that priority is set to specific options rather than check if it changed):

issue.priority?.name == '1-4' || issue.priority?.name == '5,6' || issue.priority?.name == '7'

 

1 answer

1 accepted

1 vote
Answer accepted
Florian Bonniec
Community Champion
February 23, 2024

Hi @Megan D 

 

Have you try 

if (issue.priority?.name == '1-4' || issue.priority?.name == '5-6' || issue.priority?.name == '7') {
return issue.priority?.name != originalIssue.priority?.name
}

Regards

Megan D February 23, 2024

That didn't end up working, however, I finally figured something out. I made it a bit simpler.

Instead of checking if the priority was changed from the original, it checks to see if the priority is one of other options.

Working code:

issue.priority?.name == '1-4' || issue.priority?.name == '5,6' || issue.priority?.name == '7'

 

Suggest an answer

Log in or Sign up to answer