Hi All,
The scriptrunner behaviour is not responding for simple code given below. I could not find logs for the same to troubleshoot.
Is there a way to troubleshoot?
const selectField = getFieldById("customfield_25428");
// Six Short Text fields
const targetFields = [
getFieldById("customfield_25429"),
getFieldById("customfield_25430"),
getFieldById("customfield_25431"),
getFieldById("customfield_25432"),
getFieldById("customfield_25433"),
getFieldById("customfield_25434")
];
// Field that triggered the Behaviour
const changedField = getChangeField();
// Current value of the Single Select field
const selectValue = selectField.getValue()?.value;
// Check whether this execution was triggered by
// the Single Select field being changed
const selectFieldChanged =
changedField?.getId() === "customfield_25428";
if (selectValue === "No") {
// If No, always enforce:
// 1. "Not Available"
// 2. Read-only
targetFields.forEach(field => {
field.setValue("Not Available");
field.setReadOnly(true);
});
} else if (selectValue === "Yes") {
if (selectFieldChanged) {
// User actually changed the Single Select to Yes.
// Clear previous "Not Available" values.
targetFields.forEach(field => {
field.setValue("");
field.setReadOnly(false);
});
} else {
// Form loaded with Yes already selected.
// DO NOT clear existing user-entered values.
// Just make the fields editable.
targetFields.forEach(field => {
field.setReadOnly(false);
});
}
}
Thanks