Page 1 of 1

Unable to quit chore using ChoreQuit

Posted: Mon Nov 18, 2013 2:31 pm
by ViRa
Hi all,

I have a TI process that checks the value of an element from a cube and executes a command (vb script to trigger email) accordingly. I have scheduled a chore to run this process every minute.

However, once the condition has been satisfied, I want to quit the chore. To achieve this, in the Epilog tab of the TI process, I have written the IF condition to check for the value of the element and execute command and ended it with ChoreQuit;. On activating this chore, I've noticed that the chore keeps running (thereby sending emails every 1 minute) despite the ChoreQuit;.

I've tried breaking the code by writing the IF statement in Prolog and ChoreQuit in Epilog but it did not quit the chore either.

My Epilog tab currently looks as this -

Code: Select all

v1=CellGetS ('<cube name', 'e1', 'e2');
v2=CellGetS ('<cube name', 'e2', 'e2');
v3=CellGetS ('<cube name', 'e3', 'e2');

IF(v1@='4');
ExecuteCommand('C:\Windows\SysWOW64\cscript.exe "E:\Program Files\SendMailWithParameters.vbs"',1);
endif;

if (v2@='4');
ExecuteCommand('C:\Windows\SysWOW64\cscript.exe "E:\Program Files\SendMailWithParameters_v2.vbs"',1);
endif;

if (v3@='4');
ExecuteCommand('C:\Windows\SysWOW64\cscript.exe "E:\Program Files\SendMailWithParameters_V3.vbs"',1);
ENDIF;

ChoreQuit;
Can somebody please guide me as to what I'm missing due to which ChoreQuit is not functioning? I really appreciate your time and efforts.

Thanks

Re: Unable to quit chore using ChoreQuit

Posted: Mon Nov 18, 2013 2:42 pm
by declanr
ChoreQuit doesn't "unschedule" the chore but just stops that 1 occurrence at its current position. So it will still run every minute and do the same thing again.

You don't seem to be telling it when it has achieved it's task and doesn't need to run any more, I'm not completely certain what the 4's are for etc but the following should give you an idea:

Code: Select all

v1=CellGetS ('<cube name', 'e1', 'e2');
v2=CellGetS ('<cube name', 'e2', 'e2');
v3=CellGetS ('<cube name', 'e3', 'e2');

n_check_send = CellGetN ( 'control_cube', 'Email Sent', 'Numeric' );

If ( n_check_send <> 0 );
           ChoreQuit;
EndIf;

IF(v1@='4');
           ExecuteCommand('C:\Windows\SysWOW64\cscript.exe "E:\Program Files\SendMailWithParameters.vbs"',1);
           CellPutN ( 1, 'control_cube', 'Email Sent', 'Numeric' );
endif;

...

ChoreQuit;

Re: Unable to quit chore using ChoreQuit

Posted: Mon Nov 18, 2013 3:04 pm
by ViRa
Thanks Declan for the reply. However, I'm unable to understand this part of the code -

CellGetN ( 'control_cube', 'Email Sent', 'Numeric' );

I'm not saving any value once the email is sent. Can you please help me understand what you meant there?

Btw, '4' is the string value of the element in the }tp_application_state}{[app number]} cube once a node is submitted in TM1 Applications.

Re: Unable to quit chore using ChoreQuit

Posted: Mon Nov 18, 2013 3:10 pm
by declanr
ViRa wrote:Thanks Declan for the reply. However, I'm unable to understand this part of the code -

CellGetN ( 'control_cube', 'Email Sent', 'Numeric' );

I'm not saving any value once the email is sent. Can you please help me understand what you meant there?

Btw, '4' is the string value of the element in the }tp_application_state}{[app number]} cube once a node is submitted in TM1 Applications.

The "control_cube" was just an example, when the email is sent if you don't want it to send next time the chore runs you need a way of telling it that it has already done the job. My code is pretty much irrelevant and it is just the sentiment of the process needing to know it has nothing to do. How you flag that fact up is entirely up to you, I would probably use a control cube or attribute somewhere.

Re: Unable to quit chore using ChoreQuit

Posted: Mon Nov 18, 2013 9:07 pm
by ViRa
Thanks Declan, it worked.

I saved the value of the element after data submission in another cube and wrote a ChoreQuit after that value is encountered. This way the chore ran only once.

Thanks again.