XMLWordPrintable

    • 2
    • 10

      Issue description

      The value of a Textarea type attribute is stored in HTML format. There's no way to change the format to plain text and no alternative if we want to use a multi-line text field

      Suggestion

      A plain text Textarea attribute or feature to disable HTML

      Use case

      The value of a Textarea attribute is copied to a Jira field. The copied values have HTML tags that do not mean anything in a Jira field that uses Wiki markup.

      Workaround

      • Use Insight post function with groovy script to remove all HTML tags and put the resulting text into a Single Line text custom field. An example script can be found in this comment:
        • Use the Insight post function with a Groovy script to remove all HTML tags and put the resulting text into a Single Line text custom field. An example script can be found in this comment:

          Use the Insight Groovy Script postfunction and use the script below.

          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(10107)); // Change ID (10107) to the correct Insight Customfield id
          
          ObjectAttributeBean textAreaValue = objectFacade.loadObjectAttributeBean(insightObjects.first().getId(), "Text Area Attribute") //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(11000) // 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
          

          You will need to adjust the script as commented in it:

          • Change ID (10107) to the correct Insight Customfield id'
          • Change "Text Area Attribute" with the name of the Text Are attribute you wish to use
          • Change ID (11000) to the correct Text Customfield

          The Script will look at the Object selected in your Insight CF, get the TextArea Attribute content (identified by the Attribute Name) - remove all HTML Tags, and put the resulting text into the Single Line Text CF.

            Assignee:
            Unassigned
            Reporter:
            Michelle Chin (Inactive)
            Votes:
            15 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: