Hi Community,
I want to set an option validator for Select List (multiple choices) field on Create transition in Jira Cloud Workflow.
Use-case:
- On Create screen, if user selects Option 1 and Option 2 in Select List (multiple choices) field
- Then show a validation error message on Create screen when user tries to click on Create button, saying that "You can't submit issue with both the Options - Select any one"
Please guide with Jira Expression using JMWE app (like Build-your-own Validator) or JSU Rule Builder or Scriptrunner Script or any other suitable validator in this case.
Thanks
Hi @Digvijay Singh Gehlot , thanks for your post.
This sounds like something you could do with a Behaviour if you already have ScriptRunner. Please check out the tutorial / documentation here - https://docs.adaptavist.com/sr4js/latest/features/behaviours
Let us know if you need other help.
Best wishes
Hi Digvijay,
Unfortunately, you would not be able to do this with Behaviours as behaviours in Jira cloud does not support setting errors on a screen.
You could do this with a workflow validator on the Create screenwhich would allow you to set an error message.
Using a validator, you could write a Jira Expression to verify that only one option is selected.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kristian Walker _Adaptavist_ and all,
Thank you for your messages and sharing useful insights on my request.
I am able to fulfil my request by using Scriptrunner Script validator and by creating necessary Jira Expression in Scriptrunner leap app on Create transition as below:
issue.customfield_XXXXX ? (
['Option 1', 'Option 2'].some(option =>
issue.customfield_XXXXX.some(selected => selected.value == option) &&
!(
(issue.customfield_XXXXX.some(selected => selected.value == 'Option 1') &&
issue.customfield_XXXXX.some(selected => selected.value == 'Option 2'))
)
) : false
This Jira expression will check whether the "Select List (multiple choices)" field includes at least one of the options "Option 1" or "Option 2", but does not simultaneously include "Option 1" with "Option 2".
Hope, this helps others too. Please let me know if it needs any further modification to generate the exact results.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Digvijay,
I am glad you were able to meet your requirement and that the expression generator helped you address this request.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am Juan and I am part of Decadis.
If using a different third-party app is an option for you, you can use our Jira Expression validator from Jira Workflow Toolbox Cloud (JWTC) to block the creation/transition when both specific options are selected in a Select List (multiple choices) field.
Use the following Jira expression in the validator (it allows the transition unless both options are present):
!((issue.customfield_XXXXX ?? []).some(o => o.value == "option1")
&& (issue.customfield_XXXXX ?? []).some(o => o.value == "option2"))
Please replace:
The validator should look like the following screenshot:
If you have any questions about how to apply this validator, please do not hesitate to contact us via our Support portal.
Best regards,
Juan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you prefer working with a UI instead of writing Jira Expressions manually, our team created Ultimate Validator, which builds the expression for you and makes these kinds of requirements much easier to configure.
Here’s how it looks for your case:
I’m from Forgappify, the vendor of the app. Ultimate Validator is included as part of the Workflow Building Blocks for Jira app.
Hope this helps! 😊
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.