In my previous article, I demonstrated how to configure a Workflow Process to set any User Lookup field to the Current User using the standard Modified By field to set a custom field named Last Updated By.
In this article, I provide additional important information that you should be aware of.
When using a Real-Time Workflow Process, there is an option to configure the Workflow Process to automatically start either after or before a Contact has been updated.
It is important to ensure that the Workflow Process is configured to automatically start After, instead of Before the designated fields on the Contact are changed otherwise the Contact Modified By value used to set the Last Updated By field will contain the previous User who modified the Contact, instead of the current User. This will result in the Last Updated By field being incorrectly set.
Here is what happens when the configuration for automatically starting the Workflow Process is set to Before the Contact is updated; i.e. Before Record Fields Change.
When creating a new Contact the Last Updated On and Last Updated By fields are correctly set to the current Date/Time and User.
However, if another User now updates one of the designated fields on the Contact the Last Updated By field is incorrectly set to the User who previously modified the Contact rather than to the current User.
e.g. incorrectly to this …
… rather than correctly to this …
If using a Background Workflow Process, there is no option to configure the process to automatically start Before a Contact has been updated. A Background Workflow Processes that is configured to automatically start when a Contact has been updated will always start After the Contact has been updated.
In this example used in Part 1 of this article, I chose to use a Real-Time Workflow Process instead of a Background Workflow Process to ensure that the update of the Last Modified On and Last Modified By fields was immediate.
This has the following benefits:
Sometimes you may encounter a scenario where you want to use a Workflow Process to set a User Lookup field on a record to the current User when there has been no corresponding creation or update of the record on which the User Lookup field is located and therefore no corresponding update of the Modified By field.
This may be because:
In this situation, one of the following two approaches might be used to ensure that the User Lookup field is correctly set to the current User.
Configure the Workflow Process with two successive Update steps as follows:
This approach works well if you don’t mind making two successive updates to the record.
Note: If you are using a Real-Time Workflow Process, ensure the Workflow Process is configured to run as the User who made changes to the record rather than the owner of the workflow, otherwise the first Update step will result in the Modified By field being set to the owner of the Workflow Process rather than to the current User. This option does not apply if the Workflow Process is started On Demand, manually, by a User, but is does apply if the Workflow Process was started automatically.
Hint: You could bundle these two Update steps into one single Action or Real-Time Child Workflow Process and then invoke that Action or Child Workflow Process from any other Workflow Process, Dialog Process or Action whenever required using a single Perform Action or Start Child Workflow step.
The following images show:
Configure the Workflow Process to first start a Custom Workflow Activity that then returns the UserId of the User that the Workflow Process is running as and then use an Update step to set the Last Updated On and Last Updated By fields from the Process Execution Time and the previously returned UserId.