For this example we are going to be using the Case Object. Our goal is to create a Button that will live on the Case Page Layout. When we press that Button, we want it to grab our UserId and make us the Case Owner. This is as simple as it gets!
Lets begin by navigating to the Flow (Setup | Create | Workflows & Approvals | Flows)
Then, hit “New Flow”
Great, now lets get to the fun stuff! Lets go ahead and grab the Record Update element and drop it on our Canvas. Name your Record Update “Update Record Owner” and then search for the Case Object.
After you Select the Case Object, we need to filter it based on the CaseId. So lets select the New Variable and make our Text Variable var_CaseId. After creating this Variable it will populate in the our criteria. That’s one perk of creating these variables on the fly.
We’ve found our ‘Record’ by filtering on the var_CaseId. Now, we need to update our Case with the OwnerId being the Running User’s Id. To do this we need to create a new variable called var_UserId. This is where we will pass in the UserId of the Running User (the person who pressed the Button).
Press OK to save this Record Update. Now, we want to Set the Record Update as our Start element by selecting the green arrow in the top right.
Notice I am saving this as a Flow and not an Autolaunched Flow. It doesn’t make a difference because an Autolaunched Flow can still be launched from a Button, but I do it to let myself know this is meant to be triggered from a Button.
Now, we’ve Activated our Flow and know what our URL is going to be, lets build our our Button!
First, lets navigate to the Case’s Buttons, Links, and Actions page (Setup | Customize | Cases| Buttons, Links, and Actions). From here, we will select the New Button or Link. If you are new to Buttons, take a look at my previous posts, Choosing your Button and Writing a Button’s URL.
Awesome, now lets update our Button URL. We want to select Detail Page Button for the Display Type, Display in existing window without sidebar or header for our Behavior, and URL for our Content Source.
For our URL we are simply going to pass in the CaseId and UserId, and then we want to be returned back to the Case once the Flow finishes. Notice, the UserId will be a dynamic value based on who presses the Button.
Click Save, and you are done! Now you can add the Assign to Me button to your Page Layout(s) and snipe the easy cases from your coworkers using the old school ‘Change Owner’ method.