How-to Parse Excel Data into a MRVS?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2019 11:41 AM
Greetings, Community!
I have a use case where I need to allow a user to upload an Excel spreadsheet via a catalog item. The spreadsheet could have more than 200 rows in it. Once uploaded, the content of the file would be parsed into a MRVS (multi-row variable set) on the catalog item they imported the spreadsheet into and then submitted.
I've poked around the Internet a bit and haven't found anything close to this use case.
Anyone have any ideas how to go about doing this?
Thanks in advance for your thoughts!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2019 05:07 PM
MRVS are stored in item_option_new_set table with type of "one_to_many",
Variables inside MRVS are stored in item_option_new table.
You can user OOB cart API to order catalog item and populate information from this spreadsheet into cart variables.
You will have to configure data source, transform map, scripts to call cart API.
Regards,
Sachin
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2019 07:38 PM
I think you can create a button in form i.e after attaching a attachment the user should click the button, so that we process in background and add fields to MRVS.
1. create a widget/macro button in form, configure button to call a script include on click of button
2. configure script include to parse the file for the current form and return the values in array of objects
script to parse file in server:
var parser = new sn_impex.GlideExcelParser();
var attachment = new GlideSysAttachment();
// use attachment sys id of an excel file
var attachmentStream = attachment.getContentStream(<attachment sys id>);
parser.parse(attachmentStream);
//retrieve the column headers
var headers = parser.getColumnHeaders();
var header1 = headers[0];
var header2 = headers[1];
//print headers
gs.print(header1 + " " + header2);
while(parser.next()) {
var row = parser.getRow();
//print row value for both columns
gs.print(row[header1] + ' ' + row[header2])
}
4. on receiving response set te mrvs with received values.
-satheesh
3. on getting response form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 12:30 AM
Please write a example of how to call a script include when a button is clicked in a widget, as GlideAjax is not working in widgets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 04:04 AM
how to get table_sys_id if attachment isn't yet submitted via widget script?