Forums

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

subtask validation from parent's field used JMWE

Tyas Iglecias
Contributor
February 5, 2021 edited

Hi guys,

I have 3 field :

1.  Vendor (A) : Text Field (multi-line) 12038
2.  Developer (B) : User Picker (multiple users) 12443
3.  SQA (C) : User Picker (multiple users) 12444

fields will be filled in Parent workflow,

I will make validation in sub-task used Linked Issues Validator (JMWE app)

Status Movement from open to in progress if :

A Empty + B Empty +C Empty= stop
A Empty + B filled +C Filled = move
A filled + B filled +C Filled = move
A filled + B Empty +C Empty = move

but I try my script and the result not same with my needs

(linkedIssue.customfield_12038 == null && linkedIssue.customfield_12443.length == 0 && linkedIssue.customfield_12444.length == 0)
||
(linkedIssue.customfield_12038 == null && linkedIssue.customfield_12443.length > 0 && linkedIssue.customfield_12444.length > 0)
||
(linkedIssue.customfield_12038 != null && linkedIssue.customfield_12443.length > 0 && linkedIssue.customfield_12444.length > 0)
||
(linkedIssue.customfield_12038 != null && linkedIssue.customfield_12443.length == 0 && linkedIssue.customfield_12444.length == 0)

the result  :

A Empty + B Empty +C Empty= stop
A Empty + B filled +C Filled = move
A filled + B filled +C Filled = move
A filled + B Empty +C Empty = stop


Capture.JPG

please help me for corrections related to what i have made

Regards,
Tyas

3 answers

1 vote
David Fischer
Community Champion
February 8, 2021

Apparently, Jira expressions return "" for an empty multi-line text field (instead of null). Therefore, the script should be:

(!linkedIssue.customfield_12038 && linkedIssue.customfield_12443 != null && linkedIssue.customfield_12444 != null)
||
(!!linkedIssue.customfield_12038 && linkedIssue.customfield_12443 != null && linkedIssue.customfield_12444 != null)
||
(!!linkedIssue.customfield_12038 && linkedIssue.customfield_12443 == null && linkedIssue.customfield_12444 == null)
0 votes
Tyas Iglecias
Contributor
February 7, 2021

Hi @David Fischer ,

After used your script, result is :

A Empty + B Empty +C Empty= move
A Empty + B filled +C Filled = move
A filled + B filled +C Filled = move
A filled + B Empty +C Empty = move

Are there any settings I missed?

0 votes
David Fischer
Community Champion
February 5, 2021

Hi @Tyas Iglecias ,

that's probably because, when a multi-user picker field is empty, it doesn't return an empty list but null. Therefore, you should not test the length against 0 but the field against null. Also, your first test is incorrect, since it will pass if all 3 fields are empty. Generally, you need to think in terms of every case where the validator should pass.

(linkedIssue.customfield_12038 == null && linkedIssue.customfield_12443 != null && linkedIssue.customfield_12444 != null)
||
(linkedIssue.customfield_12038 != null && linkedIssue.customfield_12443 != null && linkedIssue.customfield_12444 != null)
||
(linkedIssue.customfield_12038 != null && linkedIssue.customfield_12443 == null && linkedIssue.customfield_12444 == null)

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events