I have a Asset and a Asset referenced field in a screen. The Asset referenced field lists values based on the Asset field. I am trying to clear the Asset referenced field whenever the Asset field is changed, so that users can select values for the Asset referenced field. I used the below behaviour script. But the value doesnt get cleared. Any help on this is appreciated. Thanks!
Hi @Anusha Wilson ,
in my opinion the probel is related to .getCustomFieldObjects().findByName() method. It should return a list of custom fields.Please try the follwoing code :
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
def category = getFieldById("customfield_27000");
def subcategory = getFieldById("customfield_27002");
def selectedCategory = category.getValue();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField myField = customFieldManager.getCustomFieldObjectByName("Category_A");
def fieldValue = underlyingIssue!=null?underlyingIssue.getCustomFieldValue(myField).toString():null;
def is_retained = (fieldValue!=null && fieldValue.contains(selectedCategory.toString()))?true:false;
if(fieldScreen.name.toString().contains("Edit")){
if(!is_retained){
subcategory.setFormValue("")
}
}
Let me know,
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.