I am using Jira Software 8.4.3 and ScriptRunner 5.6.7.1-jira8
Using Behaviors, I have a custom field which is a dropdown list and when the value "Yes" is selected, I expect to see 2 other custom fields to change to "required". When I switch back to a value of "No" I expect to see the other 2 fields NOT required and hidden or read only. I have found forum posts online to do all of this, but I am not seeing any real time changes when the dropdown values are changing, which was behavior seen in tutorial videos.
If I update the JIRA issue and re-open that issue, only then do I see that the other two fields have become required.
I believe this question is also asking about seeing this "dynamic" changing of required/not required on the fly:
https://community.atlassian.com/t5/Adaptavist-questions/Updating-Fields-dynamically-in-Jira-Service-Desk-Portal-with/qaq-p/832735
At the bottom of this the person asking the question has put the following code:
if ((getFieldById(getFieldChanged()).value as Priority)?.name == "High") { ... }
I think this is what I am looking for but as I have a custom field I am not sure how to modify this to make it work for my needs.
What I have coded so far is the following:
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
def costImpField = getCustomFieldManager().getCustomFieldObject("customfield_10400");
def costImpValue = (String)underlyingIssue?.getCustomFieldValue(costImpField);
def sbirsProgImpField = getFieldById("customfield_10619")
def govtImpField = getFieldById("customfield_10620")
if (costImpValue.equals("Yes")) {
sbirsProgImpField.setRequired(true)
//sbirsProgImpField.setHidden(false)
//sbirsProgImpField.setReadOnly(false)
govtImpField.setRequired(true)
//govtImpField.setReadOnly(false)
//govtImpField.setHidden(false)
} else {
sbirsProgImpField.setRequired(false)
//sbirsProgImpField.setHidden(true)
//sbirsProgImpField.setReadOnly(true)
govtImpField.setRequired(false)
//govtImpField.setHidden(true)
//govtImpField.setReadOnly(true)
}