Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceNow incident description clubbed in JIRA description filed

Deleted user August 6, 2021

Hi,

I have integrated ServiceNow with JIRA on my ServiceNow work instance and personal instance. Issue is on work instance when I convert incident to JIRA and if the incident description is divided in paragraphs or points then it is all clubbed into a single paragraph on JIRA.

Whereas on personal instance, JIRA description retains the formatting of description from ServiceNow instance.

In both places I have used the create issue API as listed here - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

The outbound JSON payload is clubbing it into a single paragraph.

I need to retain the formatting of description from ServiceNow.

Thanks

 

2 answers

0 votes
Daniel Ebers
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.
August 10, 2021

Hi @[deleted]

just a question for clarification because I was not able to understand fully.
Are you saying you have:

1.) two Jira instances (1 work + 1 personal) where formatting of Service Now data at the end behaves differently

OR

2.) two Service now instances (1 work + 1 personal) but 1 Jira instance

For the 1.) case Community members likely will be able to dig down deeper with you whereas Service Now experts are more of a rare species here.

Happy for clarification of the setup!

Cheers,
Daniel

Deleted user August 10, 2021

Hi @Daniel Ebers 

ServiceNow's work and personal instances are connected to different JIRA instances.

Let's just think that ServiceNow work instance is connected to it's own JIRA instance and in this case I need a way to get the incident description (from ServiceNow work instance), no matter the formatting whether the description has multiple paras and bullet points etc, and set in the same format in JIRA description.

Please let me know if you need more details.

Thanks

Daniel Ebers
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.
August 15, 2021

Ah, I see. That brings some complexity with it for the scenario.

I think Nic is right when he says a deeper look into the formatted data is needed.

Somewhere there must be a difference - it must be found, then it should work.

0 votes
Nic Brough -Adaptavist-
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.
August 6, 2021

This suggests that the raw text of the Servicenow description field does not have any (valid) formatting data in it.

How are you extracting the data from Servicenow and what does the raw data look like before you put it into your JSON payload?

Deleted user August 9, 2021

Hi,

Flow is as below:

1. Getting raw data from description field in UI action (on incident table):


str= g_form.getValue('description').toString();
var res = str.replace(/%26/g, "&");

At this point I tried to replace line break with newline (then removed it):


res = res.replace(/(?:\r\n|\r|\n)/g,"\n");

2. Passing to UI page using GlideModal from within UI action:


var gm = new GlideModal('jira_issue_creation');
gm.setTitle('Create Jira Issue');
gm.setPreference('desc',res);
gm.render();

3. In UI page setting this desc in one input field:

HTML -
<g:evaluate var="jvar_desc" expression="RP.getWindowProperties().get('desc')" />

<span class="control-label" id="labelURL" for="description">Description</span>
<input class="form-control" name="description" id="description" value="${jvar_desc}" size="50" />

Processing script:
Creating object to pass to SI:

props = {
description: description.toString(),
};
new JiraIntegration().createIssue(props);

4. Reading the description in SI function -

createIssue: function(props) {

var desc = '[ServiceNow Ticket (' + gr.number + ')| ' + url + ']\n\n' + props.description;
gs.info('JiraIntegration desc: '+desc);
request_payload = this.getPayload(props);

var r = new sn_ws.RESTMessageV2('JIRA', 'Create Issue');
r.setRequestBody(JSON.stringify(request_payload));

var res = r.execute();

5. getPayload function to create request body:

getPayload: function(props) {
var prjKey=props.project.split("+");
var request_payload = {
fields: {
project: {
key: prjKey[0]
},
summary: props.short_description,
description: {
type: "doc",
version: 1,
content: [
{
type: "paragraph",
content: [
{
text: props.description,
type: "text"
}
]
}
]
},
issuetype: {
id: props.task_type
},
priority: {
name: props.priority
},
reporter: {
name: this.getUserName(props.caller_id),
},
assignee: {
name: this.getUserName(props.assigned_to)
}

}
};
Nic Brough -Adaptavist-
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.
August 10, 2021

Ok, but what is the actual payload in the JSON?  What text is going to Jira and what does the formatting data in it look like?

Sorry, I should have said, I was looking for a simple example of the formatted data going over that is getting "clubbed"

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events