Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
evason75
Contributor

Storing the 'ScriptError' value in a variable

Hi everyone,

Does anyone know how to do this???

i have tried;

LET vScriptError = ScriptError;

This doesn't work! Any ideas?

Cheers

1 Solution

Accepted Solutions
evason75
Contributor

Re: Storing the 'ScriptError' value in a variable

Hi guys

Thanks for all your help, but i've decided to go with this and it works well.

set ErrorMode=0;

load * from abc.qvw; //considering that abc.qvw doesn't exist

ErrorLog:

LOAD

'$(ScriptErrorCount)'
as vScriptErrorCount,

'$(#ScriptError)'
as vScriptErrorNo,

'$(ScriptError)'
as vScriptError,

'$(ScriptErrorDetails)'
as vScriptErrorDetails

AutoGenerate(1);

View solution in original post

7 Replies
Partner
Partner

Re: Storing the 'ScriptError' value in a variable

Hi,

This piece of code works:

set ErrorMode=0;

  load * from abc.qvw; //considering that abc.qvw doesn't exist

  let var =  ScriptError;

Regards,

Erich

evason75
Contributor

Re: Storing the 'ScriptError' value in a variable

Hi Erich

That does work, but i am looking for the ScriptError number as well as the ScriptErrorDetails.

let var =  ScriptError;

let var1 =  ScriptErrorDetails;

var = 'File Not Found' not '8'

var1 = 'null' not 'Cannot open file...etc'

Any ideas??

Partner
Partner

Re: Storing the 'ScriptError' value in a variable

Ok, I got what happened to ScriptError. Apparently, the data type is dual ( number and string).

You can get the 8 using this:

let var =  num(ScriptError);

For scriptErrorDetails, maybe it will not return a description for this case, since the 'File not Found' might be enough.

According to QV Help, it will return details for errors 3 and 4.

ScriptErrorDetails

Returns a more detailed error description for some of the error codes above. Most importantly this variable will contain the error message returned by ODBC and OLE DB drivers for error codes 3 and 4.

Hope it helps,

Erich

evason75
Contributor

Re: Storing the 'ScriptError' value in a variable

Hi Erich

Thanks for getting back. Yes the Num(ScriptError) worked well!!!

But i don't understand why you can only populate one variable.

If you run the following example var2 is populated, but if you then uncomment var1 then var2 does not update. It's as though the ScriptError variables are reset immediately after the next step??!?!

Can you think of a way of capturing all three variables?

set ErrorMode=0;

 
load * from abc.qvw; //considering that abc.qvw doesn't exist

  //let var1 =  ScriptError;

  let var2ScriptErrorDetails;

 
//let var3 =  num(ScriptError);

Re: Storing the 'ScriptError' value in a variable

Script Error is reset if the next executed statement is executed succesfully

You can use the list error details from the ScriptErrorList.

Help File:

ScriptError

Returns the error code of the last executed script statement. This variable will be reset to 0 after each successfully executed script statement. If an error occurs it will be set to an internal QlikView error code. Error codes are dual values with a numeric and a text component.

evason75
Contributor

Re: Storing the 'ScriptError' value in a variable

Hi guys

Thanks for all your help, but i've decided to go with this and it works well.

set ErrorMode=0;

load * from abc.qvw; //considering that abc.qvw doesn't exist

ErrorLog:

LOAD

'$(ScriptErrorCount)'
as vScriptErrorCount,

'$(#ScriptError)'
as vScriptErrorNo,

'$(ScriptError)'
as vScriptError,

'$(ScriptErrorDetails)'
as vScriptErrorDetails

AutoGenerate(1);

View solution in original post

Re: Storing the 'ScriptError' value in a variable

Thats it. Great!..