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
MartinKMartinK 

OpportunityLineItems Not Displaying on a Public Site (okay in regular VF Page)

Hello, I have a very simple VF Page that displays an opportunity and the opportunity line items. It works great when run within Salesforce, but when run on a public site the opportunity line items do not show up.  I have checked the public access settings and do not see Opportunity Line Items as standard object that I can grant permissions to.  Is this implied since I have granted permissions on the Opportunity? Are public sites able to display opportunity products?  Any suggestions on how to trobleshoot this.  A simplified version of the VF page is below.   Thank you so much for your help!
<apex:page standardController="Opportunity">
 <apex:pageBlock >
 <apex:pageBlockSection columns="2" >
 <apex:outputField value="{!Opportunity.name}"/>
 </apex:pageBlockSection>
 
 <apex:pageBlockSection >
    <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="item">
            <apex:column value="{!item.Description}"/> 
        </apex:pageBlockTable> 
  </apex:pageBlockSection>
 </apex:pageBlock> 

Best Answer chosen by Admin (Salesforce Developers) 
MartinKMartinK

Ankit,

 

I solved the problem, thank you so much for your help.  In order to have access to opportunity line items, pricebooks must have access.  Thank you for your help!

All Answers

Ankit AroraAnkit Arora

Hi MartinK,

 

I am unable to understand what exactly you want to say but I tried this on my org.I changed the code a bit.

 

I have given name to this visualforce page "OppShow" . Then I just added the page in my Site Profile (Setup > App Setup > Develop > Sites > Click on your site > Edit "Site Visualforce Page" > Add "OppShow").

 

After this just hit the site URL apending

yourSiteURL/apex/ShowOpp?id="any opportunityId which have line item"

 

And it shows me opportunity name and its line items.

 

 

Visualforce Page :
<apex:page standardController="Opportunity">
  <apex:pageBlock >
   <apex:pageBlockSection columns="2" >
  <apex:outputField value="{!Opportunity.name}"/>
   </apex:pageBlockSection> 

   <apex:pageBlockSection>
    <apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="item">
             <apex:column value="{!item.TotalPrice}"/>
  </apex:pageBlockTable>
  </apex:pageBlockSection>

  </apex:pageBlock>
</apex:page>

 

Hope this will resolve your problem.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 

MartinKMartinK

Ankit, 

 

Thank you so much.  The suggestion you gave has the same problem where the Opportunity Line Items renders when the VF page is run in the Salesforce App but does not render when accessed via a public site (the rest of the page renders fine).

 

 Since it is working for you, it leads me to believe the problem is in my access or security settings.   I have the Opportunity and Products Objects all given read access to the Guest User Profile and all fields are marked as visible.

 

The only clue I have is that  I do not see a way to give explicit read access to the OpportunityLineItems  object in the public access settings.  With this in mind I would think that public access on the OportunityLineItem  just matches that on the Opportunity. My guess is that I am missing a checkbox configuration parameter somewhere, I just don't know where else to look.

 

Again thanks so much for your help.

 

Best Regards,

Martin

Ankit AroraAnkit Arora

I hope you have not missed these step I want you to verify it again.

 

1) Custom page should be enabled for Guest Profile

2) Field-Level Security > Opportunity Line Item > All fields should have visible rights for Guest Profile

3) Opportunity have "Read" , "Create" rights for Guest Profile

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

MartinKMartinK

Ankit,

 

Step 1 and 3 I have done.  I do not have the option to do step 2:

 

2) Field-Level Security > Opportunity Line Item > All fields should have visible rights for Guest Profile

 

I can set field level security (and standard object permissions) for Opportunity Product and Product but not OpportunityLineItems.  My profile is Systems Administrator.  Can you confirm that you have the ability to see/modify the OpportunityLineItem field visibility.  If you do this is my problem.

Ankit AroraAnkit Arora

Yes, I can see/Modify opportunity line item FLS. Please make sure on which edition you are working. Is it Developer Edition of Enterprise Edition.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

 



MartinKMartinK

Ankit,

 

I solved the problem, thank you so much for your help.  In order to have access to opportunity line items, pricebooks must have access.  Thank you for your help!

This was selected as the best answer