- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 12:56 AM
Hello Guys,
Can anyone please point me in the right direction
Note : We have a MRV- Equipments and the values are stored in Custom table
We have developed a functionality to resubmit the catalog item with additional data and we are loading the previous values submitted earlier by the user and also Auto populating the MRV's data from the Custom table when the user selects "Resubmit existing order"
Now the Client requirement is, when ever the data in the MRV"s is Updated, added or deleted the corresponding record in the Custom table should be updated, added and deleted.
Can anyone please point me in the right direction to achieve this please?
Any suggestions will be highly appreciable!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 02:15 AM
Hi,
once catalog item is submitted in workflow run script do this
1) get the MRVS json
2) iterate it for every row
3) query your custom table with correct fields
4) determine if the row is new or existing
5) if new then insert, if existing then update the fields
6) compare the recently submitted MRVS JSON with the earlier JSON and accordingly delete the record
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 02:15 AM
Hi,
once catalog item is submitted in workflow run script do this
1) get the MRVS json
2) iterate it for every row
3) query your custom table with correct fields
4) determine if the row is new or existing
5) if new then insert, if existing then update the fields
6) compare the recently submitted MRVS JSON with the earlier JSON and accordingly delete the record
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 03:03 AM
How to uniquely identify the indivisual rows in the MRV's?
Suppose say 1st row is not updated and the 2nd row is Updated or deleted in the MRV's and 3rd row is added to MRV's , basically how to track the indivisual rows whether its updated , deleted or not
So far i was thinking to create a hidden variable inside the Mrv's and auto increment that variable for each row addition and use that unique value as a reference to Modify the corresponding Custom table records
Can you please suggest me !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 03:08 AM
Hi,
you need to compare both the JSON strings
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 10:32 AM
Hello Ankur,
The values which was entered in the MRV's first time was below
variableSetValue::[ {
"vendor" : "Microsoft",
"model" : "v1",
"rack_unit" : "metre",
"equipment_type" : "Colo"
}, {
"vendor" : "Dell",
"model" : "ACer",
"rack_unit" : "kilo",
"equipment_type" : "Flex"
} ]
Next time when the MRV data is Updated we get the below JSON string
variableSetValue::[ {
"vendor" : "Microsoft",
"model" : "v1",
"rack_unit" : "metre",
"equipment_type" : "Colo1" // Update the custom table record
}, {
"vendor" : "Dell",
"model" : "ACer",
"rack_unit" : "kilo",
"equipment_type" : "Flex"
}, {
"vendor" : "1",
"model" : "1",
"rack_unit" : "1",
"equipment_type" : "1" // Insert new Row in the Custom table
} ]
Can you please suggest me how to just compare 2 JSON strings and update/add/ delete the corresponding record in custom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 08:54 PM
Hi,
Steps
1) get the 2nd MRVS and iterate row by row
2) for each row of 2nd MRVS search in 1st MRVS and compare the values
3) if different then update
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader