Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
alutz54
Contributor III
Contributor III

Any Way to Abort a Data Load Using Script?

HI all,

I am trying to set up a schedule so that my app reloads on the second thursday of my fiscal period, which does not line up with the caledar month. My current idea is to schedule the app to reload every Thursday create an if statement in the data load editor that  looks kind of like this:

LET vToday = Today();
 
LET vFiscalPeriodEND = '2023-06-15'; // This is a placeholder, use Period data to determine end of fiscal period
 
LET vSecondThursday = Date((vFiscalPeriodEND) + 13, 'YYYY-MM-DD');
 
IF vToday <> vSecondThursday THEN
        LOAD EveryThing FROM [NonExistingTable]; // Force an error to prevent an empty upload
ELSE
        // Continue with your data load script here
ENDIF
 
If I used an endscript(), it would finish the data load and my sheet would be empty. This way, it forces an error, so the data load does not finish. The problem is that now every Thursday that is not the second of the fiscal period, I am getting an email that there was an error. This is obviously problematic because if there is an actual error, I may not see it. Is there a way that I am not aware of to force a data load abort in the data load editor script?
Labels (4)
1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

This is a bit tricky... You can exit script execution with "Exit Script" but that would leave your dataset empty. IF you force an error, as you said, you'd get a failure that you wouldn't be able to tell apart from a true failure.

Considering all alternatives, I'd probably build a process that involves 2 Apps and 2 Tasks:

1. The first App and Task only checks the calendar settings and makes a decision whether or not the reload is needed. If it's not needed, a failure is forced, to ensure that the tasks doesn't end successfully.

2. The second App and Task performs the actual reload, and the task is conditioned on a successful completion of the first task.

The benefit here is that the failure of the first task is inconsequential - nothing important is happening there. The second app if when it matters. That task will not fail, unless a true failure occurs.

Cheers,

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

This is a bit tricky... You can exit script execution with "Exit Script" but that would leave your dataset empty. IF you force an error, as you said, you'd get a failure that you wouldn't be able to tell apart from a true failure.

Considering all alternatives, I'd probably build a process that involves 2 Apps and 2 Tasks:

1. The first App and Task only checks the calendar settings and makes a decision whether or not the reload is needed. If it's not needed, a failure is forced, to ensure that the tasks doesn't end successfully.

2. The second App and Task performs the actual reload, and the task is conditioned on a successful completion of the first task.

The benefit here is that the failure of the first task is inconsequential - nothing important is happening there. The second app if when it matters. That task will not fail, unless a true failure occurs.

Cheers,

alutz54
Contributor III
Contributor III
Author

That's not a bad idea. I will likely have several apps in the coming months that can just operate off of that first app.