Determine if microflow is called by user or scheduled event

3
I'm building a microflow where I want to log the user before deleting an object. I've set this microflow as a before delete event on my entity. So this will log every delete of an object. I also have a scheduled event which is deleting old objects automatically. I don't want to log objects which are deleted by the scheduled event, so I just check following in my before delete microflow: $currentUser != empty Is there a better way to check if a microflow is called by a user or a scheduled event?
asked
5 answers
4

In case anyone reads this post nowadays (like me)...

Since Mx5 you can use the getExecutionType() method on the IContext class. You could write a simple Java action for this. The method returns one of the ExecutionType Enum constants: CLIENT, CLIENT_ASYNC, CLIENT_ASYNC_MONITORED, CUSTOM, SCHEDULED_EVENT, UNKNOWN or WEB_SERVICE.

answered
1

I would create two microflows that wrap the real microflow and pass a different value for a boolean parameter.

answered
0

You could use a java action that checks if the current context is a sudo context. If so it is run from either another microflow/java action or it is triggered from a scheduled event.

edit: blegh, my bad, you should not get the context but rather the session and check if that is a systemsession if so then it should be a scheduled event or a microflow that is triggered specifically within that system session. Other then that you cannot check if a microflow is triggered from a scheduled event. If you really want to check that in your microflow you should add an extra layer to your microflows and add a boolean as input parameter, scheduledEvent. You could then fill this boolean with the appropriate value.

answered
0

Create an entity with attributes

1.User 2.Date 3.ObjectName 4.Message

Create a microflow with parameters Object and Message. Both string.

Create an object and set the values as follow:

  1. User to current user
  2. Date to current date time
  3. ObjectName to $ObjectName
  4. Message to $Message

you can place this infront of any microflow, using a microflow call.

the parameters for the call will be objectname, which is the microflow it is placed in. and the message can be that which is being retrieved or called.

with this you can track which users are calling the microflow

Then obviously you must create a report where this will be displayed.

Maybe you can expand on this by adding a boolean parameter to check when a SE calls the microflow or something

answered
0

Your own solution is the best / simplest ;)

answered