Attach the excel of 10,000 records to RITM when user select particular value in catalog item

UjwalaBedarkar
Tera Expert

Hi,

I have used below script in workflow to generate and add the attachment but its taking time to submit the request. is it due to 10,000 records? if so, how to avoid this?

var rm = new sn_ws.RESTMessageV2();
rm.setHttpMethod('GET');
 
// Construct the URL for querying the u_opco_model table with pagination
var url = gs.getProperty("glide.servlet.uri") +
    "u_opco_model_list.do?sysparm_view=null&EXCEL&sysparm_query=" +
    encodeURIComponent('u_product_modelISNOTEMPTY');
 
 
rm.setEndpoint(url);
rm.setBasicAuth(gs.getProperty('fdx.glide.admin.user.userid'), gs.getProperty('fdx.glide.admin.user.password'));
rm.saveResponseBodyAsAttachment(current.getTableName(), current.sys_id, "Product Model Report-" + current.number + ".xls");
 
var response = rm.execute();
 
 
 
current.approval = 'approved';
5 REPLIES 5

Kieran Anson
Kilo Patron

We'll need a bit more context, where is this script running? Is it within a workflow? Can it be moved to a async activity that generates the attachment after the request is submitted. Is the request being submitted by a user? And most importantly, why is a static version of data being generated?

Hi @Kieran Anson ,

this script is running in run script of workflow and the request is submitted by user. They wanted a list of records for that custom table.

Is this being used to allow a non-fulfiller user to have visibility of a table? As you can, depending on your licensing, expose the data via the service portal in a read-only capacity without needing to have them raise a request, create an excel, and then pass it over to them.

 

Can you share a screenshot of your workflow? I assume by slow, the issue you're having is that when a user submits the request the screen is freezing (due to the workflow running synchronously) and not allowing them to do anything until the excel file is generated. A cheat solution is to add a timer at the start of your workflow - this makes it async. Timer can be just a few seconds and is the first action after the "start" action 

Hi @Kieran Anson ,

Maybe they wanted to have the attachment, hence they preferred submitting a request. I tried make asynchronous using async business rule. is that good approach?