Hi Atlassian Community,
I'm reaching out for assistance with Cloud Behaviours. Specifically, I'm trying to implement a behavior where one field becomes mandatory based on the value of another field.
Here's the scenario:
- I have a custom field called "RolloutTypeField" (customfield_10824).
- When "RolloutTypeField" has a specific value (in this case, '13217'), I want another field, let's call it "Field10762", to become mandatory. Otherwise, it should remain optional.
- Additionally, if possible, I'd like an alert or some form of notification to inform users that "Field10762" is mandatory when the specific value is selected in "RolloutTypeField".
I've attempted to achieve this using a script, but I haven't had success so far. Below is the script I've been using:
<span>// Get the RolloutType field (customfield_10824)</span>
<span>var</span> rolloutTypeField = <span>getFieldById</span>(<span>'customfield_10824'</span>);
<span>// Check if the RolloutType field has the value "13217" selected</span>
<span>if</span> (rolloutTypeField.<span>getValue</span>().<span>some</span>(<span>option =></span> option.<span>value</span> === <span>'13217'</span>)) {
<span>// If the value "13217" is selected, make the Field10762 field mandatory</span>
<span>getFieldById</span>(<span>'customfield_10762'</span>).<span>setRequired</span>(<span>true</span>);
<span>// Show an alert message</span>
<span>alert</span>(<span>'Attention! The field "Field10762" is mandatory.'</span>);
} <span>else</span> {
<span>// If the value "13217" is not selected, make the Field10762 field optional</span>
<span>getFieldById</span>(<span>'customfield_10762'</span>).<span>setRequired</span>(<span>false</span>);
}
I would greatly appreciate any guidance or suggestions on how to properly implement this behavior in Jira Cloud.
Thank you in advance for your help!
Best regards,