Page 1 of 1

How to set user to run Chore

Posted: Thu Jun 11, 2015 6:35 am
by wang_chris
When we schedule a process to run as a chore, TM1 runs the chore as user 'R*AAAAA', 'AAAAA' is chore name.

Since we use TM1user() to get current user in the precess as part of export file name, the character '*' causes abnormal file name, and lead to fail of the process.

Is there any way for us to set the user to run chore? (or to remove '*' from user name), either for that chore, or for the whole server is OK.


Regards,
Chris

Re: How to set user to run Chore

Posted: Thu Jun 11, 2015 7:09 am
by declanr
An If statement would suffice.

Code: Select all

If ( SubSt ( TM1User(), 1, 2 ) @= 'R*' );
	sUserName = 'Automated Process';
Else;
	sUserName = AttrS ( sDimClient, TM1User(), '}TM1_DefaultDisplayValue' );
EndIf;

Re: How to set user to run Chore

Posted: Thu Jun 11, 2015 8:05 am
by wang_chris
It's a good work around.

But it's the process being called uses TM1user(), I don't wish to change those processes. So I wish to set the user in the caller process.

Fortunately, I found tm1runTI can set user to call a process. Now comes a new problem, though I write the parameters same as the document specified, it always returns to me that the input paratemeters are wrong.

I have open another topic fo that.

Could somesome have a look for me, many thanks.

Chris

Re: How to set user to run Chore

Posted: Thu Jun 11, 2015 8:47 am
by lotsaram
Or you can test if the user is in the }Clients dimension, if not then the user is a chore

Code: Select all

sUser = TM1User();
If( DimIx( '}Clients', sUser ) = 0 );
   sUser = 'CHORE';
Else;
  sUser = AttrS( '}Clients', sUser, '}TM1_DefaultDisplayValue' );
EndIf;
Note if you are using CAM then the TM1_DefaultDisplayValue will be in the format Namespace/Full Name so if you want to use the user name as part of a string that will become a file name then you need to strip out illegal file name characters such as forward- and backslash. e.g.

Code: Select all

If( Scan( '/', sUser ) > 0 );
  sUser = SubSt( Scan( '/', sUser )+1, Long( sUser ) );
EndIf;
Either way wherever the process is that is using the client name as part of a file name you are going to need to change the code there.

Re: How to set user to run Chore

Posted: Thu Jun 11, 2015 2:51 pm
by BrianL
No, it's not possible to change the username a chore runs under.

Re: How to set user to run Chore

Posted: Fri Jun 12, 2015 12:05 am
by failurehappening
As a work around, the chore could call a process using TM1RunTI.exe where you have to specify which user the process runs as. This does have some drawbacks, you won't be able to use multi-commit as TM1 won't think that it's a chore any more, just a process that has been kicked off by a user.