Buttons to Enable and Manage Portal Users

  • 2
  • Question
  • Updated 3 years ago
  • Answered
Salesforce has buttons to enable and manage Customer Portal and Partner Portal users. These buttons show up on Contact page and also on Person Account pages when that feature is enabled. I need to be able to do this from within Skuid. It would be okay to have multiple buttons if that's necessary.

I'll attach screen shots for clarity..
Photo of Peter Rozek

Peter Rozek

  • 190 Points 100 badge 2x thumb

Posted 5 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
These buttons can be implemented in your skuid layouts.

Most of them are simply redirects that carry with them parameters to get you to the right place on the destination page.  These can be converted to skuid using the following process.

1.  Follow one of the redirect buttons in the standard layout.  When I selected "View Customer User" the Url is as follows: 

https://na12.salesforce.com/005U0000001dWkz?ut=c&retURL=%2F003U000000XI5sIIAT&id=005U0000001dWkz&cntc=003U000000XI5sI

2  Lets parse that out so we can make our redirect 

A. https://na12.salesforce.com   :Domain name.  Never include this in a redirect.  Using a relative link will ensure your code works moving from sandboxes to production, and if Salesforce changes the Instance of your org. 
B. /005U0000001dWkz  :The first ID.  Copy this URL into your browser (https://na12.salesforce.com/005U0000001dWkz)  to see what object this is.  In this case it is a User Id.  We will replace this number with a merge field.  The User Id has to be in a model on your contact page. Syntax like this will merge it:  {{$Model.User.data.0.Id}}  (where the User data is in the model User).  

C. Rinse and repeat for all other ID's in the query strings.  Note,  retURL parameters usually start with %2F,  which is encoding for the "/" character.  Leave those letters in your redirect.   At the end,  your redirect url will look like this: 
/{{$Model.User.data.0.Id}}?ut=c&retURL=%2F{{ContactId}}&id={{$Model.User.data.0.Id}}&cntc={{ContactId}}

3. Add a new button in a page title component in Skuid and paste that redirect url into it. 

A few final notes. 
  • Improve the user experience by conditionally displaying the right buttons.  If contacts do not have portal user accounts - show the "add" button,  If they do have portal user accounts show the "edit" and "remove" buttons. 
  • The "Log in as the user" button is different.  It is "on click javascript" and would require translating the javascript into a custom snippet in Skuid. 
  • When you put buttons in a page title,  or table row action,  pay attention to the model context.  Make sure you will have the data you need for your parameters in the model context you are using.  If for example you are on a page title connected to "contact"  you may not have the user data.  The syntaxt {{$Model.User.data.0.Id}} allows you get that "foreign model data".   If the data is in the model in context,  you just need to select the field and it will look like this:  {{ContactId}}  The data has to be in a model to be able to be passed in the redirect. 

Hope that helps. 
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
There is not a session id, I will open a ticket with SF and see what they say.

Standard Process URL:

https://na9.salesforce.com/ui/portal/EnablePRMAccountPage/e?save=1&retURL=%2F001E0000010MeKN%3Fnooverride%3D1%26sfdc.override%3D1%26srKp%3D001%26srPos%3D0%253FobjectType%253DAccount&id=001E0000010MeKN&_CONFIRMATIONTOKEN=VmpFPSxNakF4Tmkwd01TMHhPRlF4T0RveE9Eb3dNUzQ1TlRoYSxqcThCWWMyMkhYVkRqRTVZeXozZElaLE5UVTNOekJt


Custom Button URL:
https://na9.salesforce.com/ui/portal/EnablePRMAccountPage/e?save=1&retURL=%2Fservlet%2Fservlet.Integration%3Flid%3D00bE0000001ERXDIA4%26eid%3D001E0000013FTgPIAW%26ic%3D1%26retURL%3Dhttps%253A%252F%252Fskuid.na9.visual.force.com%252Fapex%252Fskuid__ui%253Fpage%253DManagePortalUsers&id=001E0000013FTgP
(Edited)
Photo of Ryan Denis

Ryan Denis

  • 542 Points 500 badge 2x thumb
Tami did you ever get a response from Salesforce on this?
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
I didn't but so far it has been working without first enabling the account. I originally had a conversation with SF and they said I had to enable the account first. Through some testing I realized I didn't. So just the button to create the portal was all I needed. Let me know if this is the case for you and I give you the code for the button.
Photo of Ryan Denis

Ryan Denis

  • 542 Points 500 badge 2x thumb
Yea that would be great thanks!
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
I added a couple more parameters to pass through to the user record. I am using this as a row action redirect URL. Let me know if you have any questions. 

/005/e?ut=P&retURL=%2F/apex/skuid__ui?page=NameofPage%3Fnooverride%3D1%26sfdc.override%3D0&cntc={{Id}}&Email={{Internal_Email__c}}&Username={{Internal_Email__c}}&name_firstName={{FirstName}}&name_lastName={{LastName}}&Alias={{Alias__c}}&CommunityNickname={{Name}}&Profile={{Portal_Profile_ID__c}}
Photo of Peter Rozek

Peter Rozek

  • 190 Points 100 badge 2x thumb
Rob, thanks for breaking this down. So far it's not quite working. I suspect that's because I'm using Person Accounts and not Contacts, which changes things a little...I think.

I'll do some more testing and will post again if I work out the syntax for the Person Account.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You will have to do the URL deconstruction regardless of where the button is coming from,  but if you follow the general steps laid out above, I think you should be able to get Person Account buttons to work.  

Just make sure that the fields you are passing into the redirect are actually live in your model when you attempt to pass them along.  Use the console and our Model API to query what is actually in the model.  The syntax in the console is  "skuid.model.getModel('<MODELNAME>').data"  (Where you replace <MODELNAME> with your actual model name).  This will show what is really in the client. 



You may also  try the ID15 value in your redirect as well as the regular ID (which is 18 characters).  Again - when you deconstruct the standard button URL count your ID length to get the correct item. 

Hope it works.