How do do you clear a value from a custom field using scriptrunner?

Justin Volden August 24, 2017

I am looking to delete the value from a custom field using a scriptrunner listener. The result should b the field no longer appears on the view form as it is empy. How would I go about this?

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Justin Volden August 25, 2017

passing a null value like I was trying is working. There was another issue with how I was setting the value on the field, it was an insights custom field which needs to be updated in a specific way if there is already a value in it apparently. 

 

Did not work:

fieldToChange.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(fieldToChange), valueToSet),changeHolder)

 

Did work:

MutableIssue mi = (MutableIssue) issue;
mi.setCustomFieldValue(fieldToChange, valueToSet);
ComponentAccessor.getIssueManager().updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), mi, EventDispatchOption.DO_NOT_DISPATCH, false);
TAGS
AUG Leaders

Atlassian Community Events