Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to load a data from a data source using a flow designer

lawrencesenpai
Tera Contributor

I need help on importing a data from an excel file using a flow designer triggered by a catalog item.

I am trying to load a data using a data source to my import set table.

All in global scope

I already created an action flow with this code :

var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportsetGr(inputs.dataSource);
var ranload = loader.loadImportSetTable(importSetRec, inputs.dataSource);
importSetRec.state = "loaded";
importSetRec.update();
outputs.importSet = importSetRec.getUniqueValue();

 

But it throws an error : Error: Can't find method com.glide.system_import_set.ImportSetLoader.loadImportSetTable(undefined,object). (Process Automation.ae416dbd1bafed10494ceb9cbc4bcbc3; line 4)

Here is my script step image: 

lawrencesenpai_0-1687431919421.png

And here is my flow

lawrencesenpai_1-1687431955936.png

 

Here is the code for my transform map action :

(function execute(inputs, outputs) {
var transformWorker = new GlideImportSeTransformWorker(inputs.importSetSysID, inputs.transformMap.getUniqueValue());
transformWorker.setBackground(true);
transformWorker.start();
})(inputs, outputs);

 

Thank you!

 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@lawrencesenpai 

I already created blog for the same few years ago; but it uses workflow.

Similar script you can try to use in flow designer

Data load and transform via Catalog Item 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@lawrencesenpai 

the error clearly says importSetRec is undefined

seems that object is not getting initialized properly

are you sending correct data source sysId

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

lawrencesenpai_0-1687438516165.pnglawrencesenpai_1-1687438530222.png

lawrencesenpai_2-1687438562492.png

The images are were I initialize the data source sys ID

And also, I will be checking your blog, Thanks!

@lawrencesenpai 

can you try to hard-code the data source sysId here?

var importSetRec = loader.getImportsetGr('sysIdHere');

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader