Transferring Ownership of an Account and its related Notes, Contacts, Opps

  • 2
  • Question
  • Updated 4 years ago
We often have to switch account ownership.  When we do this, we simply go to the standard salesforce Accounts page and next to owner it says [change].  It then takes you to an Ownership Edit page.  Here it not only transfers the account, but all notes and open activities, contacts, and opportunities.  I guess I sort of took this page for granted.

Now that we are using Skuid... changing ownership is a simple inline edit.  This initially seemed much better in that we never left the page and came back and it is all right there... However, I am now realizing that though inline edit is doing its job correctly... it is just simply changing the account owner and not transferring the account.  Therefore, all the contacts, notes, opps, etc... still remain in the old reps name.  This means that to transfer an account, we now would have to inline edit the owner as well as each and every contact on an account!  Geesh.

I was wondering if there was a way to still have that [change] option next to the owner and to take us to that standard salesforce ownership edit transfer page?  Thoughts?  I am hoping a fix similar to the [gmail] fix might work... though I would think this also may be a simple url redirect.  It appears the url says a?retURL which I assume just means return to that account ID's URL, but then I don't really know how it is getting to that transfer page... maybe "a?" means transfer page?


The gmail fix
http://help.skuidify.com/m/supercharge-your-ui/l/102526-including-gmail-to-salesforce-functionality-...
Photo of Kramer Keller

Kramer Keller

  • 330 Points 250 badge 2x thumb

Posted 4 years ago

  • 2
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I'd suggest isolating the account into it's own model so as to able to able to query the related objects and update ownership field on each of them using the ownerid on the account.

Maybe a popup with a simple field render with a custom save button with the actions to save  the "UpdateOwnerShipOnAccount" model then actions to set the "AccountID" for the "UpdateOppOwnership", "UpdateContactOwnership", etc, Update the fields and Save the Models.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
You can still get a the standard Salesforce action by using the same URL. Set up a button called "Change Owner" or something that redirects to the following URL:
/{{$Model.Opportunity.data.0.Id15}}/a?retURL=%2F{{$Model.Opportunity.data.0.Id}}%3Fnooverride%3D1%26sfdc.override%3D1
I'm assuming that your Opportunity model is called "Opportunity" but idf it's not then change the value accordingly. Now to teach you how to fish... if you right click on a link in Google Chrome and click "inspect element" you can see where salesforce is trying to send you and reproduce that link using skuid merge syntax! I right clicked on the change opportunity owner link in the standard salesforce layout and strung a URL together.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Cool trick. Never thought to use URL redirect to standard sf functionality.
Photo of Kramer Keller

Kramer Keller

  • 330 Points 250 badge 2x thumb
yeah i just used this and it worked fine - https://na4.salesforce.com/{{Id}}/a?retURL=%2F{{Id}}
Apparently the /a? is for account transfer page
I solved the data.com issues yesterday as well.  Anytime I get stuck... I look at the standard URL and try to figure out the bits and pieces.  That said, I had an issue with the data.com redirect and this account ownership redirect adn I think it may have to do with URL encoding?  I tried to transfer an account with an ampersand and it gave me an issue.  How do I fix this?  I know there is something to strip/fix url encoding.
(Edited)
Photo of Kramer Keller

Kramer Keller

  • 330 Points 250 badge 2x thumb
yes I found it from yesterday from Rob, he said the following... so I guess I have to figure out here... would I use triple brackets for my IDs?  In the case of the account with the ampersand... is URL encoding causing an issue?  I would think not in this instance right?

HTML EscapingWhen you are building URLS  you need to be careful about HTML Escaping fields.  Using the standard double brace merge syntax   {{FieldName}}  will bring in extra HTML code that is part of our standard field renderer.  For Example ID fields will be wrapped in a A Href tag so that they could be linked to.   This is great when you just want the ID field displayed on a page,  but in a URL it will break.   We provide an alternative here.   {{{Triple Braces}}} will retrieve only the data without any of the additional HTML code associated with the field type.  We recommend these with ID and Name fields. 


URL Encoding: 


If your data may have special characters or spaces in it (like name fields)  we encourage you to wrap the merge field in the following syntax {{#urlEncode}}{{FieldName}}{{/urlEncode}}   This will translate your text into URL friendly text. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Additionally, to add to the functionality presented by the URL trick by Moshe, you could add a custom multiselect field to the account  with all the names of the related objects. Then add it to the model and popup in order to be able to further set the conditions each of the related models.

Certainly more work, but keep things skuidified. :P

At this point, I think I'm going to make the same thing. Might make it it's own page in order to able to use it in other places via a page include in a popup.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
So with a quick afternoon's work this can be done declaratively in Skuid.   (However, there are some caveats). 

I built an action sequence that updates the Owner values of all rows in selected models in the page and then saves those models.  The caveat is that related data has not been loaded into the page will not be transfered.  If you have 5000 activities on a single contact,  it is going to be tough to bring all those rows into the page and update them there.  

That having been said - here is the recipe. 

1.  Create new model for "owner picker" control.   I used the contact object and selected the OwnerID and Owner.Name fields.  In advanced properties, I set model to "Create New Row"  and have Max 1 row.  This model is a dummy,  just used to source the possible new owners in a picklist.  It will never be saved. 

2. Create a popup for user to select new owner. 



Field editor in popup calls the new model created in step one. 
- Default mode set to edit. 
- Owner Id pulled onto the page - and renderer set to picklist. 

3. Create Page Title that is connected to the new model you created in step 1:



4.  Create a Reparent button with sequence of multiple actions. 



The guts of the sequence are an action for every object you want to be reparented.  For my example I used contacts.  My first action was updating the contact itself and then I added actions for Cases, Events, Tasks and Attachments.   In each Update Field on row(s) action I selected the owner field from the object, and passed the {{OwnerId}} from the model created in step 1. 

Here is a list of all actions used. 

a. Show message block UI -  Let's warn users that somthing is going on)
b. Update a field on row(s)  -  One of these for the account and then one more for each related object you want to reparent.
c. Save Models - select all the models you updated. 
d. Close topmost popup 
e. Unblock the UI.  Let the user get back to business. 


There you go.  

Now this may be more of a parlor trick than a real business solution because of the caveat identified at the beginning.  But its an example of the cool stuff you can build without any code in Skuid. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
This is what I said, except easy to read/understand. :P
Photo of Kramer Keller

Kramer Keller

  • 330 Points 250 badge 2x thumb
Very very cool

While I love SKUID, I don't need it for every page 100%.  (Though I know you all want that ;)  To have this work in SKUID redirect to the standard transfer page you can simply create a button redirect with this - https://na4.salesforce.com/{{{Id}}}/a?retURL=%2F{{{Id}}}

Of course, replace na4 with your instance
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Actually your redirect links within Skuid should be relative. It should be:  /{{{Id}}}/a?retURL=%2F{{{Id}}}  Your browser will append the first part automatically.  This way if salesforce moves you from na4 to na14 you won't have to change all your redirect links. 
Photo of Kramer Keller

Kramer Keller

  • 330 Points 250 badge 2x thumb
OH good to know - thanks