We have configured an update to a text attribute "Notes" that is triggered through a workflow post-function that sets it with the value of the custom field "Notes". Yet when the attribute is updated, it seems to pass HTML markup in the value. I have contacted support and they sent me a script as a workaround for this issue, yet when I customize the script (basically changed the IDs to the ones in our instance) I get a "GroovyInsightException: Cannot get property 'ComponentAccessor' on null object" error, which is weird as I have an object selected in the custom field. Any help?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
import com.riadalabs.jira.plugins.insight.services.model.ObjectAttributeBean
import com.riadalabs.jira.plugins.insight.services.model.ObjectBean
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);
List<ObjectBean> insightObjects = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(13011)); // Change ID (10107) to the correct Insight Customfield id
ObjectAttributeBean textAreaValue = objectFacade.loadObjectAttributeBean(insightObjects.first().getId(), "Notes") //Change "Text Area Attribute" with the name of the Text Are attribute you wish to use
String textAreaHtmlValue = textAreaValue.objectAttributeValueBeans.first().textValue
String nohtml = textAreaHtmlValue.replaceAll("\\<.*?>"," ");
def singleTextCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(12909) // Change ID (11000) to the correct Text Customfield
MutableIssue mi = (MutableIssue) issue;
mi.setCustomFieldValue(singleTextCf, nohtml) ComponentAccessor.getIssueManager().updateIssue(currentUser, mi, EventDispatchOption.DO_NOT_DISPATCH, false);
return true