Get local date in a background job or; how to use executeMicroflowAsUser_1

Hi, Here my situation: When the user submits a page on his mobile, a PDF and email has to be send. This takes quite some time and we don't want the user to wait for that. So that is all put into a background process using the CommunityCommons ‘executeMicroflowInBackground’. Works all nice except for one thing; the date that is “printed” in the PDF is using (of course) the UTC date and not the date of the user. I have tried to use the ‘executeMicroflowAsUser_1’ but somehow the object that is past is always empty. So my questions are: 1-How do I format a printable date in a process that is running on the sever, without “real” user? I can get the user(name) in the microflow, but how to use it in the format? I currently use formatDateTime($DatumTest/DateOnline,'dd-MM-yyyy HH:mm') 2-How to use the executeMicroflowAsUser_1 so that is using the passed object as argument. Thanks in advance for any help. Here is screenshot of my simple test:
3 answers

First, when using executeMicroflowAsUser_1, Arg1Name is the name of the parameter within the microflow you are trying to execute and the Arg1Value is the value assigned to that parameter. So you should only have 1 parameter, where their names match.

However, executeMicroflowAsUser_1 does not execute in the background, so best is to use the executeMicroflowInBackground java action!

As for formatting the date, I suggest you do that in the foreground using formatDateTime($DatumTest/DateOnline,'dd-MM-yyyy HH:mm') and pass the value along with the contextobject parameter in the executeMicroflowInBackground java action. This way date is always formatted in the timezone of the browser.



Currently I think there is a bug in the executeMicroflowAsUser_1 Java action. What it looks to me is that the state of the object you pass reverts to the state at the beginning of the microflow and not the state that it was when I pass the object. That might explain your empty values. I found this out in a project of ours in the last couple of weeks but have not found the time yet to try to reproduce it in a new test project (to busy finding a workaround for our translation problems we had without being able to use the Java action reliably). So we had an object, set some references and passed it to the Java action and suddenly the references where empty again. I am curious if you can come to the same conclusion. Note that we used this Java action already for quite some time. We did upgrade to 7.237 a couple of weeks ago so that might be related.





Hi Ronald,

I made a test environment and indeed… when running in background a master association does not get passed to the xxxAsUser_1 microflow. Looks like a bug.
It works fine ff running the same in foreground.
Feel free to use this simple, quick and dirty module for testing:!AiWZGu2ZzhYMgZtBSZuN-THtxPFAmg?e=TDmZQk

For those who want to see; this includes the date testing and solution. Also the one Tim proposed.