Read the Nested JSON data from one specific field in staging table and map the fields in target

Koti_developer
Tera Contributor

I've one scenario where I need to read the Nested JSON data from one specific field in staging table and identify the field mapping from Staging table to Target table to create a case with those fields based on JSON data.

 

Can anyone give basic idea on how to start or write script?

 

Thanks,

Venkat

3 REPLIES 3

Harshal Aditya
Mega Sage
Mega Sage

Hi @Koti_developer ,

 

Hope you are doing well.

 

Please take the reference of the script below

 

 

 

var testVal = source.your_field_name;
var testJSON = JSON.parse(testVal);
gs.info(testJSON.short_description);
var createInc = new GlideRecord("incident"); // Just taking example of incident table
createInc.initialize();
createInc.short_description = testJSON.short_description;
createInc.description= testJSON.description;
createInc.insert();

// Consider JSON object is
{
"short_description":"abc",
"description":"xyx"
}

 

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

 

Hi Rick/Harshal,

 

Thanks for the prompt reply! By God's grace I'm doing good!

I hope there as well.

 

Your above steps and script help me to get move ahead and try to build the script.

 

Actually, I need to configure the form to auto select the HR service based on input parameters from third party. then once identified the Service, we got to have some fields auto populated on the form, so we need to fill them by identifying/reading the JSON data.

 

Note: The data in Nested JSON may not be exact match with the field in target table fields, so we need to identify the data like USERNAMES/ID's, DATE, CHOICE VALUES (Including Glide record validations) and then match with the target field by using script considering field mapping scenarios like in images.

 

PFA for better demonstration.

 

Thanks,

Venkat

Suggestions or steps would be highly appreciated..