I have a couple of textarea fields defined in Insight.
When copying these over to a text field in an issue (e.g. Description) the content is copied over but with the HTML tags as formatting (and not rendered).
I'm guessing this is due to the fact that the Description field isn't HTML but more a richtext type of field?
Anybody know of a way/method/work around to not lose the formatting and but also not show the html tags?
Right now doing a simple copy of the content will give you a single line of text with the HTML around it..
Do the following:
will turn in to
<p>Do the following:</p><p>- 1</p><p>- 2</p>
Hi @Dirk Ronsmans ,
Insight stores the text value as (X)HTML:
ObjectFacade objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade);
List<ObjectAttributeBean> objectAttributeBeanList = objectFacade.findObjectAttributeBeans(15);
ObjectAttributeValueBean objectAttributeValueBean = it.getObjectAttributeValueBeans().find();
In the example above, in the output we would find:
<p><strong>Population</strong></p><ul><li>2021 estimate: <strong>45,605,826</strong></li></ul><p><strong>Area</strong></p><ul><li>Total: <strong>2,780,400 km2</strong></li></ul><p> </p>
Since Jira expects a different format (Jira WikiMarkup), then the above could be converted by using com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter
String fromInsight = "<p><strong>Population</strong></p><ul><li>2021 estimate: <strong>45,605,826</strong></li></ul><p><strong>Area</strong></p><ul><li>Total: <strong>2,780,400 km2</strong></li></ul><p> </p>"
DefaultWysiwygConverter defaultWysiwygConverter = new DefaultWysiwygConverter()
String wikiMarkup = defaultWysiwygConverter.convertXHtmlToWikiMarkup(fromInsight);
IssueManager issueManager = ComponentAccessor.getIssueManager();
MutableIssue mutableIssue = (MutableIssue) issueManager.getIssueObject("FOO-1");
ApplicationUser applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
issueManager.updateIssue(applicationUser, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);
For the example you have described, the above should do the trick. However, there will be conversion that will not work, requiring fine tuning.
are two helpful links for this. You're not the first :)
Thanks @Matt Doar__ LinkedIn .
I wasn't really able to find a quick solution there but I noticed my main issue was the addition of <p></p> arround the text itself.
So a simple
did the trick, I'll have to see what else comes out when we start using more formatting on the Insight objects but for now this will do :)
Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events