function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MattiasNordin.ax607MattiasNordin.ax607 

First hello world example (show contact first name on a public webpage)

Hi, Sites looks like fun. This is my first test. Can someone help me by explaining how you pass on the contact ID to the site page. The problem im having is whenever i test (dont know if i use the correct syntax) i get the...

 

"Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it. "

 

...message. Im using the following apex code on my page:

 

 

 <apex:page standardController="Contact" sidebar="false" showHeader="false">

  <h1>Mattias visual force concept page2</h1>

    <apex:form id="theForm">
     First name =  <apex:outputField value="{!contact.FirstName}"/>
    </apex:form>

</apex:page>

 

And access the page with the following URL:

 

http://flir.force.com/test/

 

So far so good.

 

But when i try to add the contact id using:

 

http://flir.force.com/test/?id=0032000000QRu5B

 

I get the authorization requred message. What am i doing wrong?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Mattias NordinMattias Nordin

That worked. Thanks.

 

The global sharing  rules were set to private. Adding the guest users to a group and sharing everything with that group solved it.

Guess i have to invent some sort of checksum security to make sure you cant pick all users by guessing the contact id string.

All Answers

BritishBoyinDCBritishBoyinDC

Make sure you have changed the Public Access settings on the site to make Contacts available to the Guest User Login.

 

Also, make sure you have updated the sharing rules to make all Contact data private, and then expose the contacts you want the public site to have access to via a sharing rule, otherwise anyone could potentially access all your Contacts...

 

 

Mattias NordinMattias Nordin

That worked. Thanks.

 

The global sharing  rules were set to private. Adding the guest users to a group and sharing everything with that group solved it.

Guess i have to invent some sort of checksum security to make sure you cant pick all users by guessing the contact id string.

This was selected as the best answer