Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,415
Community Members
 
Community Events
184
Community Groups

Make field required based on another field on Jira cloud

Edited

Can we set a custom field mandatory based on a selected value of another field on Jira cloud via scriptrunner upon closure of an issue?

For e.g., I have a custom field (can be checkbox or dropdown) named 'Has caused a delay?'. When the value for this field is Yes, then another field 'Details' will become mandatory. If the field 'Has caused a delay?' is no, then the field 'Details' is not mandatory.

I know we can do this via scriptrunner, and I am new to coding. Can someone help on this please? 

Or if there is another way around to achieve this?

Regards,

Narsha

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.
Apr 10, 2023

Hi @Narsha Bac and welcome to the community,

I found it more easy to use JMWE for such cases. You can add a workflow validator (Field Required Validator (JMWE app)) on your transition like the following:

required if.png

Replace Agent Solution with Details and customfield_10177 with the id of your "Has caused a delay" customfield.

Hi Alex,

Thanks for the prompt response but unfortunately I cannot use this app as it is not free. Any other alternatives please?

Best Regards,

Narsha

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.
Apr 10, 2023

Then try this:

issue.customfield_10004.value == "Yes" ? issue.customfield_10221 != null : false

And replace "10004" with the id of the custom field of "Has caused a delay". Test it and let me know.

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.
Apr 10, 2023 • edited

Aaand replace the customfield_10221  with the id of your "details" field

I entered the script you gave me on the validator part on the workflow but I am getting this error:

{

"timestamp": "2023-04-10T09:17:25.580Z",

"webhookEvent": "jira_expression_evaluation_failed",

"expression": "issue.customfield_13161.value == \"Yes\" ? issue.customfield_10237 != null : false",

"errorMessages": [ "Evaluation failed: \"issue.customfield_13161.value\" - Unrecognized property of `issue.customfield_13161`: \"value\" ('value'). Type null does not have any properties" ],

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.
Apr 10, 2023

@Narsha Bac what type is customfield_13161? Text, single select, or something else?

In addition let me also know the type of customfield_10237

customfield_13161 is a single select field and customfield_10237 is a text field (multi-line).

Can you please let me know the code you provided to me works for which type of field if not the ones I mentioned?

Thanks

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.
Apr 10, 2023

@Narsha Bac the above code should work for a single select and for the corresponding multi-line text. Can you paste a screenshot of your validator?

This is my validator:

Pic 1.pngPic 2.png

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.
Apr 10, 2023

@Narsha Bac this shouldn't happen, or I am missing something. When do you receive this message? After doing what exactly and what value does the 13161 CF has?

Hi Alex,

I mistakenly answered to my own post instead of replying to you. Can you delete my answer on the community please? 

The message I sent is when I checked the logs in the workflow. I managed to make it work, not sure what was wrong.

However, it is not working as expected. When I select another value for the CF 13161, for e.g. 'No', I am still getting the other field as required. CF 13161 has values: None, Yes and No.

Thanks.

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.
Apr 11, 2023

@Narsha Bac 

Hi Alex,

The message I sent is when I checked the logs in the workflow. I managed to make it work, not sure what was wrong.

However, it is not working as expected. When I select another value for the CF 13161, for e.g. 'No', I am still getting the other field as required. CF 13161 has values: None, Yes and No.

I knew there was something wrong with the line of code yesterday, but that wasn't important till we solved the error problem. Now that the error is solved, let me get back to the drawing board and get back to you!

Thanks a lot Alex. Looking forward to your response.

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.
Apr 11, 2023

@Narsha Bac 

Try the following:

issue.customfield_13161?.value == "Yes" ? issue.customfield_10237 != null : true

 Now it ought to be ok! I've tested it on my instance, and I think it works the way you want it!

Like # people like this

Yes! It is now working as expected. 

Thanks a lot for your help Alex.

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.
Apr 11, 2023

@Narsha Bac good to know that!

Kindly mark my answer as accepted in order to help others in the community with similar questions. Thank you :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events