2

Unexpected problems with email alerts after users enabled "Secure Guest User Record Access." Here are my notes on how I finally worked it out.

1 Answer 1

3

One of our clients enabled the “Secure Guest User Record Access” before we expected it, and as a result their custom visualforce pages for event signup failed. Users could go through the event site’s VF pages and enter data, but when they clicked "submit" they got an "Authorization Required" screen.

We’ve been watching for unintended consequences of the “Secure Guest User Record Access” for a while, so when all their site pages went down from one day to the next, we figured it might be involved.

The error wasn’t triggered by accessing the VF page itself, but rather when the record was saved and a confirmation email was sent to the person who signed up. The confirmation email referenced campaign and campaignMember fields which the Site Guest User no longer had access to. The message in the debug log wasn’t helpful:

System.DmlException: Insert failed. First exception on row 0; first error: TEMPLATE_NOT_FOUND, The record couldn't be saved because it triggered an email alert that failed. Please contact salesforce.com Customer Support.

We wasted some time trying to set the permissions for the template folders before we isolated the problem to “Secure Guest User Record Access”`

The instructions for adjusting to “Secure Guest User Record Access” are complicated enough that it’s easy to get at least one detail wrong, so I eventually began trouble-shooting from the bottom up.

I started with a VF page that used a standardController, so I could save it directly to the production site.

Account Name is: {!Account.Name}

I tested it using the site URL, adding the AccountId of an existing Account. My goal was to see this:

enter image description here

But until I got all the settings right, it failed and gave me the "Authorization Required Error."

To fix it I needed to:

  • Add my new VF pages to the list of enabled pages for my site;
  • Give my site’s guest user access to the account settings using the Sharing Rules. I went into the sharing settings and scroll down to the Sharing Rules.

I created a new sharing rule. (This is the step where I most often made mistakes.)

enter image description here

Here’s a rule that finally worked for me:

enter image description here

Now my test page ran in the site.

I extended my page to other objects and fields. In my case, I wanted access to the Campaign fields (and the campaignMember fields, which take their permissions from the Campaign object). So I created a second VF page to test that:

Campaign is: {!campaign.Name}

I added it to the list of VF pages enabled for the site, and I created a Sharing Rule for Campaigns. Then I tested the page, inserting the Id of an existing campaign that met the criteria in my rule (ie, it was set to Active.)

I added fields until I tested my whole page. In my case, I’m generating the VF Page from a CampaignMember record, because that gives me access to the Campaign, Lead, Contact and Account fields I need.

<p>Dear {!if(CampaignMember.Lead.FirstName==null,CampaignMember.Contact.FirstName,CampaignMember.Lead.FirstName)},</p>

            <br/> Thanks for signing up for the <strong>{!CampaignMember.campaign.name}</strong>! <br/>
            <br/>

            <strong>LOCATION</strong>: {!CampaignMember.campaign.Event_Location__c}.<br/>
            <br/>

            <strong>DATE &amp; TIME</strong>: <apex:outputText value=" "/><apex:outputfield value="{!CampaignMember.campaign.Event_Date_Time__c}"/><br/><br/>
            <strong>DETAILS</strong>: {!CampaignMember.campaign.Description_Long__c}<br/>

For the VF page, it was sufficient to simply create a sharing rule for Campaigns. The VF Page fields were all populated, and user was able to submit information.

However, the VF email template to confirm the signup left the {!CampaignMember.Lead.Firstname} blank until I also set a Lead Sharing rule. So apparently the VF email template was more demanding than the VF page.

Thanks to Peter Churchill and all you guys who've helped me figure things out,

Baird

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.