Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to make field mandatory based on another field

Vando Goncalves (e-Core)
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 31, 2019

Hi Guys.

I need to make a custom field mandatory based on another custom field value.

Example:

For example, Outage Start Date and Outage End Date will be mandatory, if I set the field "Outage" with the value "Yes".

If i was using Datacenter/Server, I'd do ths using behaviours. Buuuuuut, Cloud instance here.

 

Any guidance is highly appreciated.

1 answer

0 votes
PVS
Banned
July 31, 2019

Hi @Vando Goncalves (e-Core) 

 

You can do this, but it requires:

Here is a high level explanation so you can get an idea of what is needed.

After the issue is created, we are going to create a second transition with the same name and screen, and have it go to the exact same status. In effect, we're going to create a transition where the Workaround field is required, and a duplicate transition where it is not. And, we are going to use the Conditions to hide one of the 2 transition buttons based on the value of what is entered in the Criticality custom field.

 

How To:

 

Because you did't list the status or transition names, I'm just going to use [ Create -> Open -> In Progress ] for this example. For the transition name, I'm going to simply call it "Start".

  • From Create -> Open, the Criticality field is set based on your comment.
  • From Open -> In Progress, you hit a transition button called "Start". This will display a screen where the "Workaround" field will be set to required, or not, based on the Criticality value.
  • We are going to set one transition to display and not require Workaround, only if Criticality = Blocker
  • We are going to set the 2nd transition to display and require Workaround, only if Criticality = Non-Blocker

Steps:

  1. Open your workflow designer.
  2. Create an additional transition from Open -> In Progress, and label it "Start" to match the original. If JIRA complains about the duplicate name, then make it "Start " with a space at the end.
  3. Set the transition screen to be the same screen the original "Start" transition is using.
  4. NOTE: From here on out, I will refer to the transitions as "Start 1" and "Start 2" so we can keep them separate.
  5. Open the Conditions view on Start 1
  6. Click Add Condition, select Script Condition (a feature of Script Runner Plugin), click Add
  7. Click on Simple Scripted Condition
  8. A list of links will display below, Click on "Has custom field value equal to"
  9. This will populate a quick code snippet in the field above
  10. Change 'SomeCustomField' to 'Criticality' (include the ' ' single quotes)
  11. Change 'Some Value' to 'Blocker' (again, include the ' ' single quotes)
  12. Click Add button at the bottom
  13. Start 1 transition button will now only display if Criticality = Blocker
  14. Open the Conditions view on Start 2
  15. Click Add Condition, select Script Condition, click Add
  16. Click on Simple Scripted Condition
  17. Click on "Has custom field value equal to"
  18. Change 'SomeCustomField' to 'Criticality' (include the ' ' single quotes)
  19. Change 'Some Value' to 'Non-Blocker' (again, include the ' ' single quotes)
  20. Click Add button at the bottom
  21. Start 2 transition button will now only display if Criticality = Non-Blocker
  22. Open the Validators view on Start 2
  23. Click Add Validator, select Fields Required, click Add
  24. Select Workaround, click Add >> button
  25. Click Add button at the bottom
  26. Start 2 transition now requires Workaround
  27. Publish Workflow

We just did 2 things

  • Set 2 transitions to display/hide based on value of Criticality
  • Set the 2nd transtion that shows when Criticality = Non-Blocker, to require Workaround field

Please note that setting a field as required through the Validator transition does not display a required asterisk, but it is actually required.

 

 

In cloud Version Also Script Runner Is Available 

 

 

Thanks,

Venkatesh

shetty
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 1, 2019

@PVS  is it possible with JMWE scripted condition?

we do have same requirement

Suggest an answer

Log in or Sign up to answer