- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:15 AM
I have description field in Snow as -
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 ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 07:25 AM - edited ‎07-28-2023 07:28 AM
@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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 05:58 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 11:24 PM
Hii,
This does not works, it returns null value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 06:30 AM
@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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 11:25 PM
By using this, it returns invalid JSON format