Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
herard_bertrand
Partner - Creator II
Partner - Creator II

Qlik Sense script, is it possible to manually exit script with errors

Hello,

In Qlik Sense, in the load script. If a result of a variable is wrong, i'd like to interrupt the Script.

It's easy to interrupt the script : I use a if then else, and an EXIT SCRIPT; when I need to.

But is there a way to EXIT SCRIPT as an error ? I mean, when I do an EXIT SCRIPT, the reload stops, but in schedulers the reload appears as a successfull reload. Is there a way to exit script as a failed reload ? 

(I'm looking equivalent to exit code = 1) 

Thanks 
Best Regards  

Labels (2)
4 Solutions

Accepted Solutions
Or
MVP
MVP

@herard_bertrand  Had a look at doing this in Cloud, this should work:

IF 1=1 then

Load * from NotReal.qvd;

End if

View solution in original post

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @herard_bertrand 


Alternatively if you dont like the alert just do something like this: 

IF zVariable = 'Wrong value' then 

Load * From [lib://ThisDoesntExist/FailHere.Qvd](qvd); 

End if; 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

View solution in original post

rwunderlich
MVP
MVP

You can do it like this to avoid any syntax flags:

Set vFail=;
IF 1=1 then
  Set vFail = 'Fail here!';
End If
$(vFail)

-Rob

View solution in original post

OlivierDubois
Employee
Employee

June 2026 update for anyone landing here from search: this is now possible natively with the Exit Error statement, added in Qlik Cloud as of June 2026, and coming to next client-managed releases.

//Exit error
Exit Error 'Load validation failed';Copy code to clipboard

//Exit error when a condition is fulfilled
Exit Error 'Source connection unavailable' when vConnectionOk=0;Copy code to clipboard

//Exit error unless a condition is fulfilled
Exit Error 'Required variable is missing' unless len(trim(vRequiredVar))>0;

 

Exit Error now marks the reload as failed, surfaces your message in the script log, and raises no syntax warnings in the editor. No workarounds needed.


Full reference: https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlS... 

View solution in original post

9 Replies
JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @herard_bertrand 

I have had this as well - just do something like this. 

IF zVariable = 'Wrong value' then 

fail here;

End if; 

"The word fail here is just in text so this will cause the application to fail" So in the script it looks like this 

JandreKillianRIC_0-1743067118951.png

 

Regards Jandre

 

 

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

herard_bertrand
Partner - Creator II
Partner - Creator II
Author

That's an interesting workaround. 

I'm just not a fan of the constant alert of the syntax check, but it works 😉

thanks

Or
MVP
MVP

*Presenter voice* Then you're just going to love our new... quotes!

IF 1=1 then

'fail here';

End if;

 

I also do not like the alert. 🙂

herard_bertrand
Partner - Creator II
Partner - Creator II
Author

Heu... thanks but I still have the alert 😉 (I'm working on Qlik Cloud not On Premise maybe this is a difference) 

Or
MVP
MVP

@herard_bertrand  Had a look at doing this in Cloud, this should work:

IF 1=1 then

Load * from NotReal.qvd;

End if

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @herard_bertrand 


Alternatively if you dont like the alert just do something like this: 

IF zVariable = 'Wrong value' then 

Load * From [lib://ThisDoesntExist/FailHere.Qvd](qvd); 

End if; 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

herard_bertrand
Partner - Creator II
Partner - Creator II
Author

OK, it will due,

Thanks

rwunderlich
MVP
MVP

You can do it like this to avoid any syntax flags:

Set vFail=;
IF 1=1 then
  Set vFail = 'Fail here!';
End If
$(vFail)

-Rob

OlivierDubois
Employee
Employee

June 2026 update for anyone landing here from search: this is now possible natively with the Exit Error statement, added in Qlik Cloud as of June 2026, and coming to next client-managed releases.

//Exit error
Exit Error 'Load validation failed';Copy code to clipboard

//Exit error when a condition is fulfilled
Exit Error 'Source connection unavailable' when vConnectionOk=0;Copy code to clipboard

//Exit error unless a condition is fulfilled
Exit Error 'Required variable is missing' unless len(trim(vRequiredVar))>0;

 

Exit Error now marks the reload as failed, surfaces your message in the script log, and raises no syntax warnings in the editor. No workarounds needed.


Full reference: https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlS...