- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 08:21 AM
Hello All,
I am configuring an integration through scripted rest api.
The requirement is to allow special characters as well from the JSON payload.
Below is the code. Could you please help me how can I modify the script to allow special characters/how can I do unicode conversion.
var InsertIncident = Class.create();
InsertIncident.prototype = {
initialize: function() {},
ProcessInsertIncident: function(requestData, response) {
var validJSON = this._checkJSONValidity(requestData);
var reqeustJSONParser = JSON.parse(validJSON);
var responseBody = {};
if (validJSON) {
var inc = new GlideRecord('incident');
inc.addQuery('correlation_id', reqeustJSONParser.id);
inc.query();
if (inc.next()) {
if (reqeustJSONParser.state == '3') {
inc.state = reqeustJSONParser.state;
inc.hold_reason = reqeustJSONParser.hold_reason;
inc.contact_type = reqeustJSONParser.contact_type;
inc.assignment_group = reqeustJSONParser.assignment_group;
inc.assigned_to = reqeustJSONParser.assigned_to;
inc.approval = reqeustJSONParser.approval;
inc.work_notes = reqeustJSONParser.work_notes;
inc.update();
responseBody.Message = 'Incident is Updated';
}
} else {
inc.initialize();
inc.caller_id = reqeustJSONParser.caller_id;
inc.short_description = reqeustJSONParser.short_description;
inc.description = reqeustJSONParser.description;
inc.comments = reqeustJSONParser.comments;
inc.correlation_id = reqeustJSONParser.id;
inc.insert();
responseBody.Message = 'Incident is Created';
responseBody.Number = inc.number;
}
response.setBody(responseBody);
}
},
_checkJSONValidity: function(validJSON) {
try {
return JSON.stringify(validJSON);
} catch (e) {
gs.info('parsing error' + e);
}
},
type: 'InsertIncident'
};
Thanks,
Priya.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 10:06 AM
iT SHOULD EVEN MAP THE VALUES EVEN MAP THE VALUES TO THE FIELD WITH SPECIAL CHARACTERS UNTIL AND LESS WE DO REGEX TO RESTRICT IT .
please mark sure your field that you are trying to map is a string field and hope you are accessing the JSON value correctly like below
reqeustJSONParser.your_Json_element_value;
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2022 10:06 AM
iT SHOULD EVEN MAP THE VALUES EVEN MAP THE VALUES TO THE FIELD WITH SPECIAL CHARACTERS UNTIL AND LESS WE DO REGEX TO RESTRICT IT .
please mark sure your field that you are trying to map is a string field and hope you are accessing the JSON value correctly like below
reqeustJSONParser.your_Json_element_value;
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 06:52 AM
Hi
I even checked for configuration item field on incident table. The value is populating including special character.
Thanks,
Priya.