mapping JSON feilds to importset table feilds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 11:41 PM
Hi team
im trying to map the feilds in the json req to my importset table feilds.
example json
{
test1 ="abc",
test2="cdf"
}
my import set fields that i want to map to above
u_test1
u_test2, how do i map these? i know its possible using scripted REST API but i want to use import set api for this, any insights are appreciated
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 05:42 AM
Hi @Its_Azar ,
After you receive the response you can trigger a import set API integration to your instance. It will automatically insert into your staging table and will run your transform map.
Here is a sample script you can configure the same in flow actions.
//Create a JSON object to insert into your staging table for simplicity I have taken only one fields var incJson = { "u_short_description":"test" }; var res = JSON.stringify(incJson); try { var r = new sn_ws.RESTMessageV2('test import set API', 'create incident'); // Repleace with your rest message name request.setRequestBody(res); var response = r.execute(); var responseBody = response.getBody(); var httpStatus = response.getStatusCode(); gs.log(responseBody); } catch(ex) { var message = ex.message; }
Below is the rest message replace the rest end point with your staging name.
Regards,
Mohammad Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 09:35 AM
hi there thanks for the response, but i dont want to use the rest message or scripted rest msg, is it possible to map the incoming json feilds to import set feilds manually?? without rest api or scripted rest
Kind Regards,
Mohamed Azarudeen Z
Developer @ KPMG
Microsoft MVP (AI Services), India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 05:58 AM - edited 07-04-2025 06:03 AM
@Its_Azar ,
Or you can Go to System Definition > Scheduled Jobs and create a new scheduled job.
Here is the script for the scheduled job:
var parsedResponse = JSON.parse(responseBody);
var Data = parsedResponse.data;
//Loop through each record and insert data into import set table
for (var eachData in Data) {
var imprt = new GlideRecord("IMPORT SET TABLLE");
imprt.initialize();
imprt.setValue('u_field1',Data.field1);
imprt.setValue('u_field2',Data.field2);
imprt.insert();
};
responseBody is your JSON Body.
Regards,
Mohammad Danish