Assign to Me Button

One common scenario that many people using both Lead Queues and Case Queues face is the pain of assigning the record to themselves.  A workaround that I see many people suggesting to use (and previously have always used) was to create a JavaScript button that would do the magic for you.  I’ve seen throughout the Salesforce community people seeming to run up against walls with the code not quite working.  This is often because they are Admins/Declarative Developers trying to dabble in code.  This blog is one that I’ve been meaning to write for a while, because it solves this problem with just using Flow.  Because its a very simple Flow and a different use case than beginners typically see, it gets people realizing what they can actually do with Flow!

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)

Navigate to the Flow

Then, hit “New Flow”

Create 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.

Record Update 1

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.

var_CaseId

Record Update 2

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).
var_UserId

Record Update 3

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.

Record Update 4

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.

Save the Flow

Now, on our Flow Detail page we can see our Unique Name (API name for the Flow) and our Flow URL.  We are going to be using this in just a second to create our Button’s URL that will do all the magic!

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.

Create Case Button

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.

Assign to Me Button URL

/flow/Assign_To_Me?var_CaseId={!Case.Id}&var_UserId={!$User.Id}&retURL=/{!Case.Id}

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.

16 thoughts on “Assign to Me Button

  1. Eric Dayal January 26, 2016 / 8:19 pm

    Thanks for this tutorial, very useful. I followed the steps and it works great for me as the administrator, but my users get an “Insufficient privileges” error. What could be causing that?

    Like

    • David Litton January 26, 2016 / 10:31 pm

      The issue with that would typically be that your Users don’t have the permission in their Profile to Run Flows. Take a look at their Profile and add that permission, then you should be set!

      Like

      • Eric Dayal January 27, 2016 / 4:03 pm

        That did it, thanks David!

        Like

  2. Allan Serena April 19, 2016 / 2:25 pm

    Thank you for a great and easy to follow tutorial. Nice to learn new stuff.
    I have added it to our one of our case layouts and now my users ask if Case Status could be updated as part of the assign process. I have tried adding it to URL of the detail page button but without any luck. I would really appreciate your input.

    Like

    • David Litton April 25, 2016 / 4:40 am

      Hey Allan, sorry for the late response I was traveling. Yes you can do that. You will need to make that update in your Record Update. You want to find the Status field as another field to update, and then populate the Status your users would like to to be. The downfall of this is that it would be static to the button, unless you gave them a screen. Let me know if that doesn’t solve your question!

      Like

  3. ido greenbaum May 29, 2016 / 5:42 pm

    Thank David for this useful post.
    One quick question – can you suggest any elegant method to add the ‘Assign to Me’ Custom Link to the Case Feed layout (without having to add the ‘Custom Button’ related list that means – real estate in the Service Console is veery expensive)?

    Thank you,
    Ido.

    Like

  4. Jim November 9, 2016 / 9:13 pm

    Hey David,

    Question for you. I am using the lightning version of cases. When I run this button, on the refresh, it initially takes me to the salesforce classic view and then within 2-3 seconds converts back to the lighning / console view. Is there anyway to force the refresh to only load in the lighning/console view?

    Like

    • David Litton November 16, 2016 / 2:37 am

      I assume you would have to adjust the redirect URL. I’ll add that to my list of things to explore. I’ve not run into that issue myself yet to where I’ve spent the time on looking into it yet.

      Like

  5. Alan Kinsley February 6, 2017 / 4:01 pm

    Hey David,

    First of, huge fan of your blog, it has helped me IMMENSELY.

    Second, I have a use Case that I need help with. We use Email2Case and often get spam email or emails that users need to easily Close as Spam from the List View. I created a Flow, PB, and button that tie all together to make this happen. However, when I click the button in the List View, nothing happens, and I get no Error message.

    Any help from the Flow guru would be a great help!

    Thanks!
    Alan Kinsley

    Like

  6. Sourav March 20, 2017 / 7:50 am

    Hi David

    I did exactly the same way and I have a system admin role , I didn’t had the Run flow ticked in the profile which I added to my name through a permission set. But I don’t know why the ” Assign To Me” Button is not working. Its just not changing the owner to me. Any suggestion plz how to make it work. Even I tried assigned to other profile and gave Run flow permission in their custom profiles but till its not changing the owner. plz suggest , what can be the issue? Thanks

    Like

    • David Litton March 21, 2017 / 1:18 am

      I would double-check the variables are all setup correctly. With a URL it is case sensitive, so if you have a difference in spelling in your URL vs the Flow it won’t match and send in the right ID. Give that a shot, and let me know if it doesn’t solve it.

      Like

      • Sourav March 21, 2017 / 6:41 am

        Hello David, Thanks for your reply. I checked both and I can find a little differenc between the variables.
        My URL was : /flow/Assign_To_Me?var_CaseId={!Case.Id}&var_UserId={!$User.Id}&retURL=/{!Case.Id}

        and my variables was : {!var_CaseID}, so I changed it to ID and it worked.

        Like

  7. Anthony N Cristy Piaia June 15, 2017 / 2:46 pm

    Hello David, I followed the steps and the link is working but a page is opening within another page with the Header and tabs, no matter what choice i put, new page, within page without header and side bar it is behaving the same way. Any suggestion on what might be going on.

    thanks,

    Anthony

    Like

    • David Litton June 15, 2017 / 4:15 pm

      Validate your Button is Setup as “Display in Existing Window without Sidebar or Header”. If so, then you should be fine. If still having the issue after that, are you in Lightning Experience or Classic?

      Like

  8. mike August 14, 2017 / 1:14 pm

    thanks. really useful. I did try to do the same but in the search layout. So I did add a button but not in the page layout but in the search layout. It does not work obviously, any idea how to do so?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s