How to make some fields (system and custom) required if system field got value?

Serj Shcherbakov August 24, 2015

Hi!

I have Components field.
and if Components value = Bug i need to make Description (system), Date (custom Date), Select list (Single) as required.

How i can do this? 

 

3 answers

0 votes
Serj Shcherbakov August 26, 2015

Hi @Alejo Villarrubia [Adaptavist], I solved it is.
My code, for newbies:

! issue.components*.name.contains ('Bug') || issue.description as boolean
! issue.components*.name.contains ('Bug') || cfValues['Office'] as boolean
! issue.components*.name.contains ('Bug') || cfValues['Date of the bug detection'] as boolean

Thank you so much for cowork!

0 votes
Betsy Walker {Appfire}
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2015

Hi @Sergey Shcherbakov -

If you want to avoid code, you can use the Update on Transition for JIRA add-on from Bob Swift Atlassian Add-ons which comes with a validator named "Conditioned Validator."

With this, you would:

  1. Add a validator to the appropriate transition of your workflow, and choose "Conditioned validator"
  2. For Condition 1, type "%transition_components%:%transition_description%#%transition_MyDate%#%transition_MySingleSelect%#" into the first box (without the quotes), "Bug:.*##.*" into the second box (without the quotes), and select the Negative checkbox. This says to compare the concatenation of the Components field, description field, a custom datepicker field named MyDate and a custom Single Select List named MySingleSelect to a Regex expression that contains "Bug:" and nothing else (which it would be if any of those 3 fields were empty. The Condition1 must be true to "pass" the validation so we use the Negative checkbox to negate all this, in essence saying "as long as those concatenated fields don't match "Bug:" and nothing else, then all's good! wink
  3. The Message field provides the text the user sees if this validation is NOT passed.
  4. This screen print shows it all:
    uot-1.png
  5. Click Update, then you should see something like this (color coding used to separate the fields):
    uot-2.png
  6. Publish your draft workflow and you should be all set.

Please note:  The above assumes the Component, Description, MyDate, and MySingleSelect fields are all visible on the transition screen, which is why they are referenced with a prefix of "transition_".  If any are NOT on the transition screen, then replace the "transition_" prefix with "original_".

Hope this helps,
Betsy

 

0 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 24, 2015

Hi Sergey,

You can add a Simple Scripted Validator for each of those fields that checks whether the component has Bug as value or not.

You can find some examples of how to do that in the following snapshot of what will be the new documentation website, which will be released together with the next version of the add-on: https://scriptrunner.adaptavist.com/3.1.5-SNAPSHOT/jira/recipes/workflow/validators/simple-scripted-validators.html

Suggest an answer

Log in or Sign up to answer