6

I have a problem in production where, when users activate their account via Site.createPortalUser, instead of the User being linked to the existing Contact a new Contact is created. (Any advice on that problem very welcome too.) The logic for this is in a managed package.

I can't reproduce the problem in my managed package development org. So to debug this and test a solution, I've created a developer sandbox from production. But the activation always fails with:

Your request cannot be processed at this time. The site administrator has been alerted.

and I note that the "Used Licenses" is zero in the sandbox (but not in production). So I am wondering if Site.createPortalUser does not function in a sandbox by design. Any insight appreciated.

5
  • 1
    Check if community published and Self-registration enabled in your sandbox
    – Raul
    Commented Jan 23, 2017 at 12:46
  • 2
    @RahulSharma The Site works in other aspects and the "Customer Portal" settings have "Login Enabled" checked and are linked to the Site. The sandbox is a developer copy and all the configuration I can see is the same as in production. Is there anything specific you suggest I double check?
    – Keith C
    Commented Jan 23, 2017 at 13:07
  • 1
    If you have a live community that's configured for testing that you can access from an external link, any production command should also work in the community.
    – crmprogdev
    Commented Jan 23, 2017 at 16:17
  • How do you set accountId in your code when you call Site.createPortalUser? Do you reference existing account in the sandbox?
    – steals
    Commented Jan 24, 2017 at 5:45
  • @steals The sandbox code is a copy of the production code (and is inside a managed package) and sets the Account Id to the non-null Account reference from an existing Contact.
    – Keith C
    Commented Jan 24, 2017 at 8:34

1 Answer 1

1

Yes, this method works in sandbox, production and every other org where Sites/Communities are enabled.

There are 3 steps required to make Site.createPortalUser works correctly:

  • Login and Self registration is enabled for your portal/community
  • Account record is created that holds all contacts of external users (in your code you should reference to this account)
  • A role is assigned to the Account owner

If some error occurs during self registration you as System Administrator should receive the email from Salesforce with some details about the error. (If you don't receive any email please check "Deliverability" option in sandbox and set it to "All emails")

1
  • The problem was that I did not have "A role is assigned to the Account owner" in the sandbox because I'd created a new Account for testing there using the SA Account. Thanks very much for your help!
    – Keith C
    Commented Jan 24, 2017 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .