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

Mathieu Lepoutr
Mega Guru

Hi surbhi_123 

How are you?

 

Try this please 🙂

 

var description = current.description; 
var multilineDescription = description.join('\n'); 

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

 

This modification should help properly map the multiline description. 

Its my understanding that Exalate would be perfect for a use-case like this. It is an integration solution that works super fast in my opinion. I have been using it for quite a while and it instantly jumped in my thoughts reading this post.  Hope to have helped you and have a great day!

Hii,

This does not works, it returns null value.

Arun_S1
Tera Guru
Tera Guru

@surbhi_123  JSON encode method is used to create a string from a JSON object, here Description is not a JSON object, it is already a string and hence you need not use the encode method.

 

Skip the other lines of the code you have shared earlier and try only with the below line.

 

sm.setStringParameterNoEscape("description", current.description);

Please mark the appropriate response as correct answer and helpful.

Thanks!!

By using this, it returns invalid JSON format