Determine if a server action is called from timer

In the first production use of a server action, someone used the action inside of a timer, and it blew up, because I used the function GetUserID() to determine the username. Is there a way to determine if your action is being used inside a timer so that you can avoid calling problematic functions?


Right-click on the action -> Find usages in all Modules (or Ctrl+F12) to find all usages of the action.

All the best

Thanks, but I mean from inside the function, as it runs. For example, using an IF statement, "IF <running inside a timer>" = TRUE, then USERNAME = "System", If FALSE, then USERNAME = <filter server action GetUser by ID = GetUserID()>.

Hi Joseph! 

I believe your problem answer the question.  Use whatever value is the response you are getting now when call the action from the timer, to compare with the GetUserID()  response. 

But I would create an input parameter "IsFromTimer" , set it correctly in each call and test it in the beginning of the action.  




Hi Joseph,

I would do like Maria Peixoto said! However, in otherway you can make an if with the GetUserId().

If(GetUserId() = NullIdentifier()) is because it's a timer, else you're using it inside some server action. Just be careful if you're using this action on anonymous pages.



HI Joseph Marlin

The best approach is on action you should create a boolean input parameter, to make some  if conditions.

Example: When you wake the time, set the boolean to TRUE, so User=adminstrator.
If the action is call by an user, set boolean to FALSE, so USER = GETUSERID().

Best Regards,

Thanks, all, for the input. This is a lower-level function in a Service Module, called by other functions, so the developer might not even know it exists, much less be able to control the input parameters. I like the thinking, but I think I might test Tiago's suggestion. That would be my preference.