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.

Abort the scheduled data import through Pre-script script.

ankit19
Tera Contributor

I need to abort the scheduled data import from Excel, based on checking headers of imported Excel sheet.

From Below script I'm able to get the headers name in system logs but cannot find a funtion which I can call inside the if(header1 != 'Allocation Logic') to abort the import submission.

 

ankit19_1-1683121805024.png

 

 

25 REPLIES 25

Then something else is not working. I have just did a test to confirm this.

I used script:

2023-05-04_1.png

 

Every time I hit "Execute Now", new rows are added to the import set row table.

I change the script to:

2023-05-04_2.png

 

and no matter how many times I press "Execute Now", no new rows are added to the import set row table.

thomaskennedy
Tera Guru

Consider what to do if that query on line 25 doesn't find anything. I think you want to abort the import in that case.

Slava Savitsky
Giga Sage

In the "Transform Scripts" related list, create an onStart transform script, move your code in there, and use either

ignore = true;

or

error = true;

to stop the transformation if your header check condition is not satisfied.

Hi @Slava Savitsky  This will ignore the imported data to insert in the table but the requirement is to restrict the data source execution while importing excel.

Here is what product documentation says about conditions in scheduled jobs:

 

SlavaSavitsky_0-1683302686776.png

 

Try adding the following to your code as the last line:

answer;