MultiLine Description field not getting mapped to Jira Description field

surbhi_123
Tera Expert

I have description field in Snow as -

surbhi_123_0-1690373565802.png

I am using BR for integration as -

var description=current.description;
var json = new global.JSON();
description = json.encode(description);
sm.setStringParameterNoEscape("description", description);

The value is not getting updated to Jira Description field, it is updated as blank.

The above code works fine for single line text but not for multiLine text. How to map MultiLine description field ?

1 ACCEPTED SOLUTION

@surbhi_123 My REST API call was perfectly working fine when the description had a single line, it failed when there were multiple lines.

 

I have modified my script as below and the REST API call started working fine

 

var desc_split=inc_rec.description.split('\r\n');
 r.setStringParameterNoEscape('description',desc_split.join('\\r\\n'));

 

 

This is my entire script to trigger the REST call, where the queried incident has multiple lines in my description.

 

 try { 
 var inc_rec=new GlideRecord('incident');
 inc_rec.addQuery('number','INC0010146');
 inc_rec.query();
 inc_rec.next();

 var r = new sn_ws.RESTMessageV2('VK REST API', 'Create Incident');
 var desc_split=inc_rec.description.split('\r\n');
 r.setStringParameterNoEscape('description',desc_split.join('\\r\\n'));
 var response = r.execute();
 var responseBody = response.getBody();
 var httpStatus = response.getStatusCode();
 gs.info(responseBody);
}
catch(ex) {
 var message = ex.message;
}

 

 

Please mark the appropriate response as correct answer and helpful.

Thanks!!

View solution in original post

6 REPLIES 6

@surbhi_123 My REST API call was perfectly working fine when the description had a single line, it failed when there were multiple lines.

 

I have modified my script as below and the REST API call started working fine

 

var desc_split=inc_rec.description.split('\r\n');
 r.setStringParameterNoEscape('description',desc_split.join('\\r\\n'));

 

 

This is my entire script to trigger the REST call, where the queried incident has multiple lines in my description.

 

 try { 
 var inc_rec=new GlideRecord('incident');
 inc_rec.addQuery('number','INC0010146');
 inc_rec.query();
 inc_rec.next();

 var r = new sn_ws.RESTMessageV2('VK REST API', 'Create Incident');
 var desc_split=inc_rec.description.split('\r\n');
 r.setStringParameterNoEscape('description',desc_split.join('\\r\\n'));
 var response = r.execute();
 var responseBody = response.getBody();
 var httpStatus = response.getStatusCode();
 gs.info(responseBody);
}
catch(ex) {
 var message = ex.message;
}

 

 

Please mark the appropriate response as correct answer and helpful.

Thanks!!

It still sends invalid json format. The log value sent is -

"description": {
"type": "doc",
"version": 1,
"content": [{
"type": "paragraph",
"content": [{
"type": "text",
"text": "Requested For = Shalika Sinha
Short Description = jk
More details about the issue = jb
"
}]
}]
},