How to Update User Selected Multiple records using Workflow
Requirement is to execute a workflow process for each record of multiple selections made by user on the UI. For instance, if a user was on a list applet and user had randomly selected records say #1,#3 and #5 from a list of 10 records in the UI, workflow must be executed only for the user random multiple selected records.
Follow the below steps to implement this requirement using a scriptless solution.
1. Create a workflow “Update Selected Activity” with very basic steps to update a field on the UI.
Example: Let us try and update a field called ‘Description’ on the Activity with a value called as “Updated via Workflow”
Configure the “Update Activity” Step in workflow as below:
a. Set the Field Input Arguments:
b. Set the Search Spec Input Arguments as below:
c. Publish this workflow.
2. The second step is to add a custom button on the list applet:
Expose this button on the applet using Edit Web layout:
3. Go to your BC on which the list applet is based on and expand to create new records in BC User property as below:
Name: Named Method
Value: “SelectionUpdate”, “INVOKESVCSEL”, “Action”, “Workflow Process Manager”, “RunProcess”, “‘ProcessName'”, “‘Update Selected Activity'”, “‘Object Id'”, “[Id]”
Note: This user property is used to invoke the workflow.
Name: Named Method 1
Value: “SelectionUpdate”, “INVOKE”, “Action”, “RefreshBusComp”
Note: if you do not add this User property, then you need to explicitly perform refresh records to view your changes on the UI. Moreover, if you skip this user property, you will see only one record updated on UI. Explicit refresh will help you see update on all the selected records.
4. Compile the list applet and its corresponding BC.
When you invoke this button on the UI, Selected records will be changed as shown below:
How to confirm your workflow has run only for your selected records:
Follow the steps below:
1. Go to the below view and increase the monitoring level of your workflow “Update Selected Activity” to “Debug – Level 4” :
2. Run the requirement using your custom button on the list applet and then navigate to Administration – Business Process -> Workflow Instance Monitor and query with the name of workflow as “Update Selected Records” to see on what records the workflow has run as shown below:
Happy Learning !!