Displaying custom error messages after running a process in PAW

Ideas and tips for enhancing your TM1 application
Post Reply
luizg2019
Posts: 33
Joined: Thu Sep 12, 2019 11:02 pm
OLAP Product: TM1 - PAW & Architect
Version: PA 2.0.7 - PAW 2.0.44
Excel Version: office 2016

Displaying custom error messages after running a process in PAW

Post by luizg2019 » Sun Dec 06, 2020 9:01 pm

Hello, ever since Planning Analtics Workspace 2.0.43 when a process execution results in errors, the error log line is displayed directly in PAW. More info about this here.

We can use this feature to display a custom error message directly in the PAW window using the ItemReject TI function, it will reject a source record and place it in the error log with a custom error message. The syntax is something like this:

Code: Select all

If (ErrorCondition=True);
   ItemReject ('Error Msg');
EndIf;
And the error will be displayed like this:

Image


Observations:

If you use ItemReject in the Prolog section, it will skip the rest of code under it and go straight to the epilog tab.
A good approach to this if you have code in your epilog tab is to use something like this:

Code: Select all

#PROLOG

If (ErrorCondition=True);
  vError=1;
  ProcessBreak;
EndIf;

#EPILOG

If (vError=1);
   ItemReject ('Error Msg');
EndIf;
If you have a metadata/data section, it will skip only a single record and process the rest. So it's a good idea to place a ProcessQuit function in the metadata and data sections.

Code: Select all

#PROLOG

If (ErrorCondition=True);
  vError=1;
  ItemReject ('Error Msg');
EndIf;

#METADATA and #DATA

If (vError=1);
   ProcessQuit;
EndIf;
Also there's seems to be a bug (I don't know if it's fixed in the latest versions of PAW or not, I already notified IBM about it) if you have the 'Language=something' parameter in your tm1s.cfg file, it won't show the log on the error messsage in PAW, but if you remove this setting and restart the server it should work.

Thanks!
Last edited by luizg2019 on Wed Dec 09, 2020 5:49 pm, edited 2 times in total.

lotsaram
MVP
Posts: 3534
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Displaying custom error messages after running a process in PAW

Post by lotsaram » Mon Dec 07, 2020 8:49 am

luizg2019 wrote:
Sun Dec 06, 2020 9:01 pm
If you have a metadata/data section, it will skip only a single record and process the rest. So it's a good idea to place a ProcessQuit function in the metadata and data sections.
Well actually there's a much better approach. In the condition where you ItemReject just convert the process on the fly to having no data source. The Metadata and Data tabs will then be skipped and the process will proceed straight to the Epilog.

E.g.

Code: Select all

If( some condition @= 'TRUE' );
    DatasourceType = 'NULL';
    ItemReject( 'Your custom error message here' );
EndIf;
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.

luizg2019
Posts: 33
Joined: Thu Sep 12, 2019 11:02 pm
OLAP Product: TM1 - PAW & Architect
Version: PA 2.0.7 - PAW 2.0.44
Excel Version: office 2016

Re: Displaying custom error messages after running a process in PAW

Post by luizg2019 » Wed Dec 09, 2020 11:22 am

lotsaram wrote:
Mon Dec 07, 2020 8:49 am
Well actually there's a much better approach. In the condition where you ItemReject just convert the process on the fly to having no data source. The Metadata and Data tabs will then be skipped and the process will proceed straight to the Epilog.

E.g.

Code: Select all

If( some condition @= 'TRUE' );
    DatasourceType = 'NULL';
    ItemReject( 'Your custom error message here' );
EndIf;
Wow, great idea!
Thanks.

Post Reply