Parsing multiple excel sheets at the same time

Mahesh Murikipu
Tera Contributor

I have a scenario where I have to create multiple catalog requests from excel and yes which can be handled using ExcelParser API and Cart API. The next step of it is to create a mrvs to accept till 7 rows and create the same number of tasks as present in the mrvs and wait till all the catalog tasks are completed, which can be achieved through flow designer.

So, now the expectation is to create multiple catalog requests along with the mrvs rows from same excel in two different sheets. I did not find a way to do this via import set cause I have to parse the the first sheet in excel for the actual variables and second sheet for the mrvs variables. Is something like this possible using import set?

 

My approach was as below:

-> Create a custom table for handling excel data as in the proper validation and population of sys_ids of reference fields and dependent choice options. I would do all such validations while import into this custom table.

-> The custom table will now have the proper data and a status field value set as "Verified" which will be picked up by schedule job.

-> The schedule job will pick up such records from this custom table and start creating a payload and send it back to the CartAPI. For the response received, set the custom table record status as 'success' and update the record with the Request No.

 

Screenshot 2024-07-07 at 5.03.40 PM.pngScreenshot 2024-07-07 at 5.08.35 PM.pngScreenshot 2024-07-07 at 5.08.39 PM.pngScreenshot 2024-07-07 at 5.08.42 PM.png

 

var obj = {
	"sysparm_requested_for":"6816f79cc0a8016401c5a33be04be441",
	"sysparm_opened_by":"77af05b383030210a4869530ceaad3b5",
	"sysparm_quantity":"1",
	"sysparm_id":"be90d9f383030210a4869530ceaad39f",
	"variables":{
		"requested_for":"6816f79cc0a8016401c5a33be04be441",
		"requested_by":"77af05b383030210a4869530ceaad3b5",
		"fill_in_details":{},
		"request_type":"single",
		"text":"",
		"date":"",
		"category":"",
		"options":""
	}
}
var grRec = new GlideRecord('u_catalog_records');
grRec.addEncodedQuery('u_status=verified');
grRec.query();
while(grRec.next()) {
	obj.variables.fill_in_details = JSON.parse(grRec.u_mrvs);
	obj.variables.text = grRec.getValue('u_text');
	obj.variables.date = grRec.getValue('u_date');
	obj.variables.category = grRec.getValue('u_category');
	obj.variables.options = grRec.getValue('u_options');
	var cart = new sn_sc.CartJS();
	var cartdetails = cart.addToCart(obj);
	var checkoutInfo = cart.checkoutCart();
	grRec.setDisplayValue('u_request_created', checkoutInfo.request_number.toString());
	grRec.setValue('u_status','success');
	grRec.update();
}

 

0 REPLIES 0