JMWE or some other tool: mandatory fields depending on the choice of single select field

Jurica Petricevic
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.
May 11, 2023

Hello everyone,

 

I have the following problem not only when creating a ticket, but also when editing a ticket in the future after creating it.

Field 1 (single select field) has a minimum of four values, say A, B, C, D, E, and in case A, B or C is selected, Field 2 (Date field) must not be empty and must be filled with a date, and Field 3 (Text Field) must also not be empty. If the value D or E is selected, these two fields may be empty.

 

Is this possible to do?

 

Best regards

1 answer

1 accepted

2 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

Hi @Jurica Petricevic 

I would add a scripted JMWE validator with the following script:

if (issue.getRawValue("customfield_SINGLESELECT_ID")?.value in ["A", "B", "C"])
{
issue.get("customfield_DATEFIELD_ID") != null && issue.get("customfield_TEXIFIELD_ID") != null
}

On the above code replace the ID of the custom fields with your IDs.

Let me know if you managed it!

Jurica Petricevic
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.
May 12, 2023

@Alex Koxaras _Relational_ Hi, 

thx for your time mate.

 

Scripted (Groovy) Validator 

my script isnt working for some reason he doesnt chk the value in the field

if (issue.getRawValue("customfield_16100")?.value in ["R", "G", "P"])
{
issue.get("customfield_13651") != null && issue.get("customfield_13203") != null
}

 I have to choose a For filed Box, what should i pick there or leave it empty?

I am not sure why doesnt work. Can you help me here some more?

 

Best regards

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

@Jurica Petricevic I dont understand the "I have to choose a For filed Box". Try to do a validation of your script first:

test.png

And paste an image of what you are getting.

Jurica Petricevic
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.
May 12, 2023

@Alex Koxaras _Relational_ we needed 

else true

now it works.

if (issue.getRawValue("customfield_16100")?.value in ["R","G","P"])
{
issue.get("customfield_13651") != null && issue.get("customfield_13203") != null
}
else true
Jurica Petricevic
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.
May 12, 2023

@Alex Koxaras _Relational_ Thx a lot. Your on my beer list :)

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 12, 2023

You got to hold on to that promise @Jurica Petricevic🍺🍺🍺🍺

Suggest an answer

Log in or Sign up to answer