Setting Updated By column in Flow not working for Action Update Record; sets it to system

BabyYoda
Tera Expert

I have a Flow which calls the "Update Record" action on a Task record. I see that it is automatically setting the sys_updated_by column on the record. This is not ideal, as I have a notification which triggers on a record update. The notification reads int he sys_updated_by value. As a result, it's displaying the system User. There is a mail script which performs a lookup on the sys_user table. The lookup will fail for the system user.

 

What I want to do is prevent the Flow from updating the sys_updated_by column with the system user, thus preserving the sys_updated_by column to its previous value.

 

I have tried creating a custom Action with a script that sets the sys_updated_by column of the current record and I disable auditing, i.e. currentRecord.sysAutoFields(false). I added this custom Action to my Flow; this custom Action runs immediately after the "Update Record" Action. While this preserves the sys_updated_by column after the Flow has run, the issue is the notification is still being fed the system user, because the "Update Record" action is triggering the notification.

 

I've tried setting the sys_updated_by column as another field in the "Update Record" action, but I see that it's ignoring it and still setting the column value to the system user. I even tried hitting the drop down on the column to expand the script, set it via script and included the following in an attempt to turn off sysAutoFields:

fd_data.trigger.current.autoSysFields(false). No dice. Still says it was updated by system.
 
I have other solutions I can use, of course. I can abandon Flows and go straight to scripting, modify the notification trigger mechanism and conditions, flow conditions, etc. but the whole point is I want to make it work with the Flow and enforce it to respect the Updated By column when it updates the record and make as few changes as possible. You would think this shouldn't be brain surgery for the Flow to respect the sys_updated_by column value that you specify during a record update.
 
Is there a way to run a script within the Flow, either from a script include, or just a global script to the Flow such that it respects the Updated By column value I specify and does not update the record with the system user? Or, is this a limitation of the "Update Record" action and the only recourse if I want to use the Flow is abandon the "Update Record "action and and employ a custom Action exclusively, creating a script that updates the record and sets the sys_updated_by field? 

 

Thank you for your time.

 

All the best!

2 REPLIES 2

Mani A
Tera Guru

tricky but lets try like this.. check who updated from updatedby field if they updated some fields on task and re-update  the same updatedBy field after system user had updated. 

It is tricky. Yes, I've done that step already. That's where my custom Action comes into play; it updates the sys_updated_by column, but it's already too late as the "Update Record" action has committed the changes, triggering the notification with the System user record as the sys_updated_by column value.

 

I just read up that the "Update Record" action does not respect journal fields and that may include the sys_updated_by column. If that is the case, I can try impersonating the previous sys_updated_by user during the Flow,  just prior to execution of the "Update Record". And then end impersonation after "Update Record" action completes. That might work. Otherwise, it's going to get a little too cute and then I'm full-on XY problem mode. Which means I'd probably have to fall back to removing the "Update Record" action, and use my own custom action to update the record--I'm confident this should work because it's all script-based and it will respect whatever I set for the sys_updated_by column.

 

The problem comes down to--I think--the "Update Record" action ignores journal fields and that might include auditing fields such as sys_updated_by. Impersonating another user may work. If not, then it all has to be done in a custom action to update the record while setting the sys_updated_by field, which I think should do the trick.