- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 09:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 10:20 AM
To create a record in a service table from a JSON response, you will need to follow these general steps:
1. Parse the JSON response: Use a JSON parser to convert the JSON response
2. Extract the relevant data
3. Connect to the service table
4. Insert the data
------------------------------------------------------------------
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
initialize: function() {},
createRecordFromJSON: function(jsonResponse) {
var responseObj = JSON.parse(jsonResponse);
var name = responseObj.name;
var email = responseObj.email;
var age = responseObj.age;
var gr = new GlideRecord('your table');
gr.initialize();
gr.name = name;
gr.email = email;
gr.age = age;
gr.insert();
}
};
// Usage example
var jsonResponse = '{"name": "John Doe", "email": "john.doe@example.com", "age": 30}';
var myScriptInclude = new MyScriptInclude();
myScriptInclude.createRecordFromJSON(jsonResponse);
---------------------------------------------------------------------
Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!
I invite you to checkout below items for more interesting and knowledgeful ServiceNow stuff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 10:20 AM
To create a record in a service table from a JSON response, you will need to follow these general steps:
1. Parse the JSON response: Use a JSON parser to convert the JSON response
2. Extract the relevant data
3. Connect to the service table
4. Insert the data
------------------------------------------------------------------
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
initialize: function() {},
createRecordFromJSON: function(jsonResponse) {
var responseObj = JSON.parse(jsonResponse);
var name = responseObj.name;
var email = responseObj.email;
var age = responseObj.age;
var gr = new GlideRecord('your table');
gr.initialize();
gr.name = name;
gr.email = email;
gr.age = age;
gr.insert();
}
};
// Usage example
var jsonResponse = '{"name": "John Doe", "email": "john.doe@example.com", "age": 30}';
var myScriptInclude = new MyScriptInclude();
myScriptInclude.createRecordFromJSON(jsonResponse);
---------------------------------------------------------------------
Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!
I invite you to checkout below items for more interesting and knowledgeful ServiceNow stuff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 08:23 PM
how the json looks like?
you can parse the json and iterate and then insert
what did you start with?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader