How To

Assign a Record to Me

Make life simpler for your users by giving them the ability to assign a Salesforce record to themselves with a click of the button on the record detail page.

In support of #NoCodeNovember, for the entire month of November, there is a success community group (@No Code November) dedicated to finding creative ways to deliver features to customers without one line of code.

Read the post on Button Click Admin 5 Reasons to Go #NoCodeNovember to learn more about the group’s genesis.

Here is a use case solved by clicks instead of code in Salesforce Classic.

(Note: This will not work in Lightning Experience.)

Here are a few lessons learned from implementing this use case:

  • Provide descriptions, where provided, in Salesforce. This may be tedious step, I know, but your future self will thank you when you are trying to remember what you configured or assist other/future admins when troubleshooting or enhancing what was built. This includes noting what a custom button does, where visual flow is invoked from, the purpose of a flow variable, etc.
  • For any data actions (fast and record lookup, create, update and delete actions), best practice is to include a flow element to send an email to your Salesforce administrator about the fault.

Flow trick: To getting the Fault connector to appear, either draw the regular connector link to another flow element or connect it to a temporary flow element. Draw the fault connector to the Send Email element. Then, go back and delete the regular connector.

  • When passing variables in an URL, please make sure the variable name is exactly as you have named it in visual workflow. The variable name is case sensitive, so “varCaseId” and “varCaseID” are not considered the same.

While this use case is about the standard Case object, this solution can be tweaked for any standard or custom object.

Business Use Case: Addison Dogster is a system administrator at Universal Container. Sammy Sunshine is an Operations Manager who requested that a CSR be able to quickly assign a case to him/herself from the case’s detail screen.

Solution: Addison was able to help Sammy using a couple of declarative actions rather than writing code. Her solution that involves a two element visual flow and a custom button.

Quick Steps:

  1. Create a visual workflow (Create | Workflows & Approvals | Flows). This will assign the case to the current user.

A. You need to create two variables. One will contain the current user’s ID (varCurrentUserID) and the other will contain the case ID.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this variable is for.

varCurrentUserID varCaseID

Note: The names of these variables are important as they will be referenced in the custom “Assign Case to Me” button. If the variable name is different than what is used in the button URL, the flow will not work.

B. Next, you will use a Record Update flow element. This will update a the case owner ID to the current user variable where the Case ID matches the Case ID variable.

RecordUpdate

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this flow element is used for.

C. Make sure this flow element is “Set as Start Element.”

StartElement

D. As a best practice, where there is a DML action (fast or record create, update, delete or lookup action) in a flow, you should also include notification of a flow fault.

Note: To avoid “hardcoding” email addresses in a fault email, refer to a post Using Custom Metadata Type in Visual Workflow Fault Emails.

Select the Send Email flow element that is listed under Static Actions, not under Quick Actions.

StaticActions

Configure the body to show the fault message, subject and email address(es).

Best Practice Tip: If you have several visual workflows, you should consider creating a custom setting to hold the email address and reference the custom setting in the fault email so if you need to change the email address or add multiple addresses, you only need to manage the email address in the custom setting and not have to go into each flow to update.

FaultEmail

You will need to draw a connector line between the Record Update and Send Email elements.

Can’t seem to get the fault connector to appear? Create a temporary flow element (circled below), draw your first connector to that temporary flow element. Then, draw another connector to the send element. This connector has the word “FAULT” in it.  

FaultConnector

Once that is completed, delete the temporary flow element you created. This is the end result.
Flow

E. Provide a name for your flow and ensure that the type is flow since this will be initiated via a button.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this visual flow is used for, where it is invoked from.

FlowProperties

F. Save the flow.

G. On the flows screen, activate the flow.

Note: The URL shown will be used in the custom button we will create in the next step.

Flow-Activate_URL

Note: The URL shown will be used in the custom button we will create in the next step.

2. The next step is to create the custom button. Go to Customize | Cases | Buttons, Links, and Actions, click on the “New Button or Link” button.

CaseButton

Provide the information in the screenshot below and save it. This custom button will appear on the case detail page in the existing window without sidebar or header.

CustomButton

Use the following as the URL: /flow/Assign_Case_Record_To_Me?varCaseID={!Case.Id}&varCurrentUserID={!User.Id}&retURL=/{!Case.Id}

/flow/Assign_Case_Record_To_Me initiates the visual flow you created in the previous step. This is the same value shown in the URL field of the visual flow.

varCaseID={!Case.Id} is passing the case ID as the value for the visual flow variable varCaseID (this needs to be an exact match to the variable name set in your visual flow)

varCurrentUserID={!User.Id} is passing the current user’s ID as the value for the visual flow variable varCurrentUserID (this needs to be an exact match to the variable name set in your visual flow)

retURL=/{!Case.Id} tells the Salesforce to return the user to the current case record detail page after the visual flow is finished with its execution.

Best practice tip: Don’t forget to provide a description so you and other/future admins know what this button is used for/what it does.

3. Lastly, you need to add the new custom button to the Case page layout in the Custom Button section via Customize | Cases | Page Layouts. Save changes to the page layout.

PageLayoout

 

That’s it. Congrats, you’ve implemented the solution!

Now, before you deploy the changes to Production, you need to test your configuration changes.

  1. Login as a customer service rep and navigate to an unassigned case record.
  2. Click on the Assign Case to Me button.
  3. Confirm that the case owner has been updated to the customer service rep and the URL is the case detail page.

Deployment Notes/Tips:

  • Confirm whether the case page layout in Production is the same as the sandbox with the exception of the new custom button. If it is, then you can add the page layout to the change set. Otherwise, add the custom button as a post change set deployment manual step.
  • The custom button, visual workflow, (and possibly, the page layout) can be deployed to Production in a change set.
  • Activate the visual flow as it is deployed to Production as inactive.

12 thoughts on “Assign a Record to Me

  1. Hi, in your second step it says to add a custom button. I have seen that with LE you will not be able to use custom buttons (Custom buttons that use a URL or JavaScript content source aren’t supported in Lightning Experience. You can replace some of the functions covered by these buttons by using point-and-click tools like Process Builder, Visual Workflow, or code-driven approaches.). Will this process continue to work after switching to Lightning Experience? Thank you!

    Like

  2. Hi Amy. This custom button only works in SalesForce Classic. With both now available, I make it a point to test it out in both and if it only works in SalesForce Classic, the post will note it as such.

    Like

  3. Hi Jenwlee, I try to create a button which will also be available in Lightning. What option do I have ?

    Like

  4. Does it work if the current user (who is clicking the button) doesn’t have Modify All permission or Transfer Record permission

    Like

  5. If you use the Quick Action to Launch the Flow how you are going to pass the variables to it? URL button doesn’t behave well in my case, it doesn’t work on the first click but it works on the second click. Do you have a working solution for Lightning?

    Like

  6. Unfortunately, you cannot pass data into flow variables using a QA. In your flow, you would use the recordId or other information to look up information or you would have passed into the variables.

    Like

Leave a comment