Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Copy the content of an Insight Textarea Attribute to a jira custom field in the same format

Edited
Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Aug 26, 2021

Hey,

I want to copy the content of an Insight Textarea Attribute to a jira custom field.
I do this with an Insight Postfunction “Set a Jira custom field with the attribute value from a selected object”
The content is copied, but the formatting is not correct. It looks like HTML-code is being copied. 

How do I make sure that the text in the jira field is displayed the same as in the Insight object?

I am now using a jira multi text field with wiki rendering.

 

Anyone tips, suggestions?

 

Thanks in advance.

 

Groetjes,
Greetings,
Marco

p.s. Attached a screenshot of the display in the jira field.

Screenshot 2021-08-26 at 10.11.35.png


And a screenshot where you can see the display in Insight and the result in jira custom field

Screenshot 2021-08-27 at 09.52.01.png

2 answers

This is actually quite a huge issue.

I am facing to this and trying to solve that last few months.

Got official Atlassian reply - it is not supported.

There are two or three workarounds.

First is to strip all HTML tags and receive a plain text - use 

textToStrip.replaceAll("\\<.*?>"," ");

Second approach is to create translation library - own method to convert html tags to wiki markup tags.

The last approach I dug somewhere deep in community is to use 

com.atlassian.renderer.wysiwyg.converter.DefaultWysiwygConverter

class from the atlassian-renderer library and call convertXHtmlToWikiMarkup method for the object.

I am planning to go with last one, but had no time to proof it is working yet.

Hope it helped, let me know in case of success. Facing very same issue.

Cheers, Tom, Czechia

Hello Tom. Certainly an old issue, but I'm wondering if you were ever able to resolve this? Thank you.

Yes, I made it, I planned to write an article about this conversion, but kind of forget about it. 

Well main reason is that the I left the company I worked on that particular project, so I have no more access to working environment with this conversion mechanism. 

But, as far as I remember, it was delivered in Adaptavist Script Runner Behaviour plugin using wysiwyg converter. 

You can actually dig into https://docs.atlassian.com/atlassian-renderer/5.0/apidocs/com/atlassian/renderer/wysiwyg/converter/DefaultWysiwygConverter.html and use methods convertXHtmlToWikiMarkup and convertWikiMarkupToXHtml depends on what you are trying to achieve. 

Will try to dig into my code backups, but not sure if I will be lucky. 

I founded a way Insight -> Jira for Behaviours

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

Class iqlFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.IQLFacade")
def iqlFacade = ComponentAccessor.getOSGiComponentInstanceOfType(iqlFacadeClass)
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade")
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass)

int implementationPlanId = 1927
String searchString = "Key"
String html = "{html}"

def catalogItem = getFieldById(getFieldChanged()).getValue().toString()
def catalogItemObject = iqlFacade.findObjectsByIQLAndSchema(1, "\"" + searchString + "\" = \"" + catalogItem + "\"")
def catalogItemId = catalogItemObject[0].getId()

def implementationPlan = objectFacade.loadObjectAttributeBean(catalogItemId, implementationPlanId)
if( implementationPlan )
{
def objectAttributeValues = implementationPlan.getObjectAttributeValueBeans()
def objectAttributeValue = objectAttributeValues[0]
implementationPlan = html+objectAttributeValue.getValue()+html
}

getFieldByName("Implementation plan").setReadOnly(true).setFormValue(implementationPlan)

This part of code actually took content of 1927 Insight attribute formatted text and prefilled it inside the "Implementation Plan" custom field within the screen.

Hope it help. 

0 votes
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Aug 30, 2021

Hi @Marco Brundel

My first suggestion would have been to update the field configuration to ensure it's a wiki rendering, but you have done that already.

Have you tried clearing the formatting on the insight object attribute? Copy and paste it to notepad.

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events