Read the Nested JSON data from one specific field in staging table and map the fields in target
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 02:42 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 03:12 AM - edited 07-25-2023 03:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 03:36 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 04:38 AM
Suggestions or steps would be highly appreciated..