Hi,
I have created 2 custom fields as below:
Custom Field 1 - Confidential Data? (Single select field)
Custom Field 2 - What kind of Confidential Data? (Text Field)
I have created the following code using Behaviours plugin (Adaptavist ScriptRunner) to make 'Custom field 2' required based on the value selected in the 'Custom Field 1' :
def clientDataField = getFieldByName("What kind of Confidential data?")
def confidentialDataField = getFieldById(getFieldChanged())
def selectedOption = confidentialDataField.getValue() as String
def isOtherSelected = selectedOption == "Yes"
clientDataField.setHidden(!isOtherSelected)
clientDataField.setRequired(isOtherSelected)
The above script is working fine for the below scenario:
If 'Yes' is selected for the 'Confidential data?' field then 'What kind of Confidential data?' field should appear to be mandatory.
If 'No' is selected for the 'Confidential data?' field then 'What kind of Confidential data?' field is set to be optional and is hidden.
However, after creating the issue, I am able to delete the entire text from the 'What kind of Confidential data' field even though the value 'yes' is chosen under 'Confidential Data?' field.
So, how to prevent users from deleting the text entered in 'Custom Field 2' after creating the issue?
Note: I cannot remove the field from the edit screen because sometimes users might need to update the text in the 'What kind of Confidential data?' field. They should be able to edit the value but not delete it when 'Yes' is selected for 'Confidential Data?' field