2 Replies Latest reply: May 12, 2016 11:06 AM by Shamsh Alam RSS

    Qlik Sense load script examples with error variables usage

    Shamsh Alam

      Does anyone has Qlik Sense load script examples where error variables are used?

       

      http://help.qlik.com/en-US/sense/2.0/Subsystems/Hub/Content/Scripting/ErrorVariables/ErrorVariables.htm

       

      I am trying out below simple script -

       

      xyz:

      load * inline [ x,y

                      1,1];

      let vScriptError = ScriptError;

      Trace $(vScriptError);

       

       

      Per the documentation, I expect it to log ‘0’ in the output. It doesn’t though. Any ideas why it's not printing 0?

        • Re: Qlik Sense load script examples with error variables usage
          Gysbert Wassenaar

          If there's no error then the errorcode is empty, not 0.

           

          Try this to see an actual error:

           

          SET ErrorMode = 0;

           

          LOAD * FROM NoSuchTable;

           

          LET vScriptError = 'Errorcode: ' & '$(ScriptError)';

           

          SET ErrorMode = 1;

          • Re: Qlik Sense load script examples with error variables usage
            Shamsh Alam

            Thanks for the reply Wassenaar,

             

            If I execute your script with slight modification , Trace does print the error message when an error is there.

             

            set ErrorMode =0;

            LOAD * FROM NoSuchTable;

            LET vScriptError = 'Errorcode: ' & ScriptError;

            Trace $(vScriptError);

             

             

            Actually per Qlik Sense help , Script Error should return 0 if no error is there.

            See this help section on Script Error  ScriptError ‒ Qlik Sense

             

            So when there are no errors, then if ScriptError=0 condition works. Problem was when I try to print the value in output. Tony Ventura from Qlik helped me out with this.


            I was basically missing '#' in front of the variable. Below will print '0'


            load * inline [ x,y

                            1,1];

            let vScriptError = ScriptError;

                 Trace vScriptError = $(#vScriptError);