Forums

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

How to check if field exists in the screen before the rest of the validator?

Thais Sales Monteiro de Sousa December 18, 2023

Hello everyone,

I'm trying to create a validator using Scriptrunner and so far I came up with the following expression:

(issue?.isEpic == false && issue?.customfield_10100 =! null) ?
    (
        (issue?.customfield_10100.value == "Sim" && issue.epic != null) ||
        (issue?.customfield_10100.value == "Não")
    ) :
    false

This works when the custom field 10100 is on the screen, but I have a few cases where the screen for the issue type in the same workflow does not have the custom field and the transition breaks

Is there a way to make this validation works only for the screens that have the field? 

1 answer

0 votes
Kristian Walker _Adaptavist_
Community Champion
December 18, 2023

Hi Thais,

Thank you for your question.

I can confirm that unfortunately validators cannot be configured for only specific screens containing specific fields as the Jira Expression framework from Atlassian,  which ScriptRunner for Jira cloud uses to provide validators does not support this. 

The Jira Expression API has a hasScreen property that can check if a transition has a transition screen but this does not support checking what fields exist on that screen during the transition.

This means the only way to solve this is to create a new workflow for the projects that require the screen and the field and this to just these projects so that projects which do not use this field are not impacted.

I hope this information helps.

Regards,

Kristian

Thais Sales Monteiro de Sousa December 18, 2023

Thank you for the reply Kristian

Do you know if I can change de first part of the expression to filter for issue types that are standart issue types?

 

instead of 

issue?.isEpic == false
Kristian Walker _Adaptavist_
Community Champion
December 19, 2023

Hi Thais,

Yes, you can check for certain issue types and I can confirm in the examples here, that the first expression on line 46 shows how to check if an issue type is a certain type such as a story or task.

I hope this helps.

Regards,

Kristian

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events