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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

scripterrordetails use in qlikview

Hi I am new to qlikview

I wanted to List the errors in the dashboard, so I chose textboxt to display them.

firstly I used "ScriptErrorList" error variable with the following if statement in the textbox,

if(ScriptErrorCount>0, ScriptErrorList , 0)

it gave the proper output, but it just gave the output like "syntax error" or "general error" not the detailed one.

so, I am using "ScriptErrorDetails" error variable for detailed error list but nothing is displayed in the textbox.

Following is the statement which I wrote in the textbox for getting the detailed error list :-

if(ScriptErrorCount>0, ScriptErrorDetails, 0)

0 is displayed when no error is there in the script, but nothing is displayed when there is error in script.

Please tell me how to use  ScriptErrorDetails in qlikview

Thanks In advance

Labels (3)
1 Solution

Accepted Solutions
iliyansomlev
Partner - Creator II
Partner - Creator II

Hi,
ScriptErrorDetails does not survive reload (I am using QV 11.2 SR5) so you have to take the information in it during script run. Even during script run ScriptErrorDetails keeps only the detail for the last error that occurred. For example if you run the script below, you will have only the error detail about the missing txt file even though ScriptErrorCount will be 2.
If you uncomment the last 3 lines the error detail about the Table not Found will also get saved - concatenated to the table ErrorDetailTable.
In similar way you have to save the value of ScriptErrorDetails after each block of code where error may occur. Note that it is written as '$(ScriptErrorDetails)'
Hope this helps;
ErrorMode =0;

MapErrors:
Mapping LOAD * INLINE [
    ErrorCode, Errors
    0, No error
    1, General error
    2, Syntax error
    3, General ODBC error
    4, General OLE DB error
    5, General custom database error
    6, General XML error
    7, General HTML error
    8, File not found
    9, Database not found
    10, Table not found
    11, Field not found
    12, File has wrong format
    13, BIFF error
    14, BIFF error encrypted
    15, BIFF error unsupported version
    16, Semantic error

]
;
//this should return error - cannot find file user2.txt
Errors:
LOAD ErrorCode, Errors
FROM

(
txt, codepage is 1251, embedded labels, delimiter is ' ', msq);
//this will create table to keep the info about the last error that has occurred
ErrorDetailTable:
LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
'$(ScriptErrorDetails)'
as ErrorDetails
AutoGenerate(1);
//this should give another error - Table not found, no other details here
DROP TABLE TTT;
//uncomment this to save the information about the second error as well
//LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
// '$(ScriptErrorDetails)'
as ErrorDetails
//AutoGenerate(1)

View solution in original post

7 Replies
iliyansomlev
Partner - Creator II
Partner - Creator II

Hi,
ScriptErrorDetails does not survive reload (I am using QV 11.2 SR5) so you have to take the information in it during script run. Even during script run ScriptErrorDetails keeps only the detail for the last error that occurred. For example if you run the script below, you will have only the error detail about the missing txt file even though ScriptErrorCount will be 2.
If you uncomment the last 3 lines the error detail about the Table not Found will also get saved - concatenated to the table ErrorDetailTable.
In similar way you have to save the value of ScriptErrorDetails after each block of code where error may occur. Note that it is written as '$(ScriptErrorDetails)'
Hope this helps;
ErrorMode =0;

MapErrors:
Mapping LOAD * INLINE [
    ErrorCode, Errors
    0, No error
    1, General error
    2, Syntax error
    3, General ODBC error
    4, General OLE DB error
    5, General custom database error
    6, General XML error
    7, General HTML error
    8, File not found
    9, Database not found
    10, Table not found
    11, Field not found
    12, File has wrong format
    13, BIFF error
    14, BIFF error encrypted
    15, BIFF error unsupported version
    16, Semantic error

]
;
//this should return error - cannot find file user2.txt
Errors:
LOAD ErrorCode, Errors
FROM

(
txt, codepage is 1251, embedded labels, delimiter is ' ', msq);
//this will create table to keep the info about the last error that has occurred
ErrorDetailTable:
LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
'$(ScriptErrorDetails)'
as ErrorDetails
AutoGenerate(1);
//this should give another error - Table not found, no other details here
DROP TABLE TTT;
//uncomment this to save the information about the second error as well
//LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,
// '$(ScriptErrorDetails)'
as ErrorDetails
//AutoGenerate(1)
Anonymous
Not applicable
Author

Hi IIiyan Somle

It seems this code will work for me. Let me try it. Will let you know

Thanks in advance.

Bhumika

Anonymous
Not applicable
Author

Hello IIiyan

Code is working absolutely fine. Thanks for help.

but I have a doubt, That if there is two consecutive errors then it will give error details for the last error, not for the first one. For eg.

Errors:

LOAD ErrorCode, Errors

FROM

(txt, codepage is 1251, embedded labels, delimiter is ' ', msq);

//this will create table to keep the info about the last error that has occurred

LOAD a as yy,

     yy

FROM

(ooxml, embedded labels, table is Sheet1);

ErrorDetailTable:

LOAD ApplyMap('MapErrors','$(ScriptError)') as ErrorType,

'$(ScriptErrorDetails)' as ErrorDetails

AutoGenerate(1);

Here, I have added a Load statement to your code where I have given same column names.

So, it is giving errordetail only for last load i.e "Field names must be unique within table".

What do you suggest? Adding For loop in this case will help or should I go for different approach?

Thanks

Bhumika

iliyansomlev
Partner - Creator II
Partner - Creator II

Hi Bhumika,

You are right and it is as  I wrote to you originally - it gives errordetail only for the last error. So I suggested copy-pasting the small code after every block of code (every LOAD statement - where you have a little hammer symbol on the left of your code). The information will automatically concatenate in just one table in the end.

I know this is not a lean solution. I tried to make a  'sub ...end sub'  code and Call it after each block of code but for some reason it didn't work well. Maybe you will find a better solution to this.

Also if you have 2 or 3 error in a block of code QV stops at the first error found and will return information/details only about this error, which is natural in most cases.

Hope this helps you somehow,

Iliyan

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You are correct that a sub won't catch the error. The error state will be reset by the Call statement. Better to use a $include that contains your error recording code after each load.

Rob

Anonymous
Not applicable
Author


ok.. Thanks IIiyan

I will try what you have suggested and let you know if I get a proper output.

Thanks

bhumika

Anonymous
Not applicable
Author

Thanks rob for the suggestion.. I will try and let you know.

Thanks

Bhumika