Hello,
i am looking for adding workflow condition using scriptrunner validator in jira.
use case - custom field A and parent field will decide nature of the error message. Both are drop down field.
i am trying below condition but it is not working as is
Hi @Arti Patil
I can confirm the approach you are trying will not work.
The validator for Jira cloud doesn't work the same as it doesn't in Jira DC / Server.
You will need to use Expressions for Jira Cloud. As explicitly mentioned in this ScriptRunner for Jira Cloud documentation, Jira Cloud Expressions do not support if/else conditions.
I suggest using ScriptRunner's Expression Generator to create your expressions. Once you have created your Expression using the Expression Generator, you can copy the code and add it to your validator.
Alternatively, you can also use the in-built Expression Builder in the validator as shown in the screenshots below:-
I hope this helps. :-)
Thank you and Kind regards,
Ram
Hi @Arti Patil
I am not sure if I get it right but I trust the below code will help you
def customFieldA = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_XXXXX"))
def parentIssue = issue.getParentObject()
if (customFieldA == "option 1" && parentIssue == null) {
return false // "Parent issue is required when Custom Field A is Option 1"
} else if (customFieldA == "option 2" && parentIssue != null) {
return false // "Parent issue must be null when Custom Field A is Option 2"
}
return true
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.