- 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-31-2022 07:58 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-31-2022 08:03 AM
Hi Ankur,
I am still working on it and i will update you once done
Thank you!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 11:30 PM
I was little bit confused to compare 2 JSON strings so what i did was, first i deleted the data from the custom table after every Update request was submitted and then added rows again to the custom table( In this way it doesnot require the need to compare whether data is deleted, added or updated on MRV's)
var orderLine = new GlideRecord('sn_ind_tmt_orm_order_line_item');
orderLine.addQuery('order', current.variables.customer_order_no);
orderLine.query();
if (orderLine.next()) {
var orderLineItemId = orderLine.sys_id;
var equipment = new GlideRecord('sn_ind_tmt_orm_equipments');
equipment.addQuery('u_customer_order_line_item1', orderLineItemId);
equipment.query();
while (equipment.next()) {
equipment.deleteRecord();
}
//To fill the values of the MultiRow variable set data in the custom table
var variableValue = current.variables.list_of_equipment;
var parser = JSON.parse(variableValue);
var gr = new GlideRecord('sn_ind_tmt_orm_equipments');
for (var i = 0; i < parser.length; i++) {
gr.initialize();
gr.u_vendor = parser[i].vendor;
gr.u_equipment_type_model_no = parser[i].equipment_type_model_no;
gr.u_quantity = parser[i].quantity;
gr.u_rack_units = parser[i].rack_units;
gr.u_customer_order_line_item1 = orderLineItemId;
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2022 02:42 AM
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader