[SalesForce] Update the last modified user to Automated Process

Is there any way I can update a field on the record through automation to make sure that the last modified user gets updated to automation process user on the record?

So, here's our issue, we have recently implemented Field Service Lightning. Our partner users will be assigned work orders which they can either accept or reject. Our automation works in such a way that when a work order is rejected through a on-screen flow, it gets assigned to other tech on basis of our scheduling policy and then, a chatter notification and FSL mobile app notification will be sent to the new tech.

Problem arises when partner user rejects and the work order is assigned to other tech, chatter and app notification specifies the previous partner user name (last modified by) which we absolutely do not want. For ex: If partner user A rejects a Work Order, partner user B would get a notification saying that A has assigned the WO. We do not want partner users seeing each other's name.

Best Answer

There's no way to do this synchronously (within the same transaction), so there's always going to be the possibility that partner users could see the original Last Modified By information. You can't ever change the running user within a non-test transaction.

To change the Last Modified By user, you'd need to fire a Platform Event from a trigger, which will be processed asynchronously - outside the current transaction - in an Automated Process context. Automation that reacts to that Platform Event, whether Process or Trigger, could read a record Id from the payload and perform some no-op update to the record, resulting in a Last Modified By of Automated Process.

But, as noted above, this may not be foolproof in achieving your ends. Any automation that's reacting within the original modifying transaction will still show the original Last Modified By, and it's likely that your Chatter automation would fall into that category. Additionally, a user who viewed the record at just the right time might still see that original value as well, prior to the time at which the asynchronous update runs.

Disclaiming that I am not experienced with Field Service Lightning, the only other route that I see is to avoid having partner users modify records at all, by bouncing all updates into the Automated Process user's context via Platform Event, or using a callout to enter the context of some arbitrary system user.

That's a rather heavy solution, and it may or may not work with your current Flow automation.

Related Topic