Audit Trial - Execute commits in executeMicroflowInBackground, user is unknown in java action
Hi all, I am uploading more than 10,000 csv records in file upload. Was trying to add audit trail during commit of objects. found that it was taking longer time to commit. As per the suggestions from forum, I am trying to put audit part into background process so that user will not be impacted with the upload. I am using executeMicroflowInBackground java action from community commons. Microflow which I am passing here will call the CreateLogObject.java from Audit trial module. Now what I found if context.getSession().getUserId() is not fetching the right user from session. Instead, its running into exception and taking Mxadmin as default user and logging as uploaded by Mxadmin. Any suggestions on this? Many Thanks in advance. Nirmal Kumar
Nirmal Kumar Moodbidri Thilakraj
Just a thought: it may be an option to not use the audit trail component at all. Personally i try to avoid tusing it because of the performance impact: it always logs while there are always quite a lot of changes in objects that are not interesting to log at all like boolean fields for internal use only.
You can easily create an auditlog entity yourself and then create logentry object at the moments that really are worth it. You have full control in that way.
That behavior is by design. Check out this line in the quite elaborate documentation-tab on executeMicroflowInBackground hava-action:
“Note that since the microflow is run as system transaction, $currentUser is not available and no security restrictions are applied.”
I have not tried this myself, but maybe you can use the contaxt object, to pass along the user, and trigger the executeMicroflowAsUser.