Setting Updated By column in Flow not working for Action Update Record; sets it to system
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2024 09:02 AM
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:
Thank you for your time.
All the best!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2024 09:27 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2024 10:59 AM
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.