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
alisonbenjaminalisonbenjamin 

Displaying Contacts in a Force.com Sites page

Hi,

 

My organization uses the Salesforce bucket model.

 

I want to be able to display a list of our Contacts of a specific Record Type using Force.com Sites. The list should be publicly viewable, and I should be able to embed it in an iframe.

 

I have a question about the Force.com Sites product: I would like end users visiting the page to be able to filter those Contacts displayed based on some search criteria (filter on data contained in Contact Custom Fields). End users should also be able to enter a freeform search to see what resulting Contacts display.


Is it possible to do the above using visualforce / Force.com Sites ?

 

Thanks

 

ForcepowerForcepower
Alison - yes - you sure can. You can write a VF page and a controller for it and expose the VF page on a Force.com site.
ForcepowerForcepower
Simple example:
public with sharing class ContactsController {

public List<Contact> contactList {get; set;}
public ContactsController() {
contactList = [Select Name, Email from Contact limit 100];

}

}

-------------------------------------------------------
<apex:page controller="ContactsController" showHeader="false" >
<apex:pageblock >
<apex:pageblockTable style="width:350px" value="{!contactList}" var="contact" rowClasses="oddPDF,evenPDF" rules="all">

<apex:column style="width:40px" styleClass="label" headerValue="Name">
<apex:facet name="header">
<apex:outputPanel styleClass="optLabel" >Name</apex:outputPanel>
</apex:facet>
<apex:outputText styleClass="optField" value="{!contact.Name}" />
</apex:column>
<apex:column style="width:40px" styleClass="label" headerValue="Email">
<apex:facet name="header">
<apex:outputPanel styleClass="optLabel" >Email</apex:outputPanel>
</apex:facet>
<apex:outputText styleClass="optField" value="{!contact.Email}" />
</apex:column>
</apex:pageblockTable>
</apex:pageblock>
</apex:page>
michael_mcmahonmichael_mcmahon

Ram@4cepower:

 

I'm also trying to display  tables of records as public Sites pages, starting with the most basic view and adding complexity over time.

 

I'm stuck. So far I've gotten two VF pages to work as Public Sites, every other page that I've attempted to link to a sSte generates an Authorization Required page.

For example, http://quickops.force.com/newperson generates an Authorization Required page.

But if I build out a new page with just the default /apex/page "Congratulations. This is your new Page.." then it displays correctly, see: http://quickops.force.com/hello

So I assume I am doing something bad in the VisualForce that is causing the need for authentication.

I have only one line of VF in each of the Sites pages, each is a variation on this for various objects: <apex:page showHeader="false" action="{!URLFOR($Action.Business__c.List, $ObjectType.Business__c)}"/>

Any help greatly appreciated.   Thank you

ForcepowerForcepower

Michael,

 

Indeed - it pops up the Authorization Required page when it encounters errors in Apex among other things. You can figure out the issue a couple of ways.

1. Try running your VF page while logged in into SF by going to something like https://na9.salesforce.com/apex/VF1 (where VF1 is your page). Any errors - such as trying to access a field without querying it in SOQL etc will show up more explicitly when running this way.

 

2. Add debug to the guest user for your site. So if your site is named quickops, you'll have a guest user named  something like "quick ops Guest user". Set debug monitoring on and then try your requests. The error should show up in the logs.

 

Hope that helps.

Best,

Ram

michael_mcmahonmichael_mcmahon

Thank you for your very quick response.

 

The pages work fine as Visualforce pages, viewed with the ..../apex/pagename technique.

 

I tried to find a way to enable debugging for guest users and was ultimately told by Premier+ support techs (two of them) yesterday that debugging is not possible on Guest profiles.  When I attempt to enable debugging, the only profiles that are available to me for debugging are those of logged in users, either our Internal Users or Customer Portal but not Guests.

 

Do you know how exactly to enable debugging for guest users, or can you point me to a workbook or guide?  

 

As it is now, if I view the pages in Administrator mode, I see this error message at teh bottom of the page;  "Page not allowed for profile:/businesses/a0T/I:  but I've checked 100 times and the page IS allowed in that Profile.

 

Thanks very much for your help, it's greatly appreciated.

 

Michael

 

 

 

ForcepowerForcepower

Michael,

 

When you go into Admin Setup | Monitoring | Debug Logs | New  - You should see a profile such as "<Site Name> Site Guest User" where <Site Name> is a placeholder for your actual site name. Just try a wild card search such as *Guest* or just put the full guest user name in such as "MySite Site Guest User". That should find it and you should be able to debug that user.

 

Best,

Ram

michael_mcmahonmichael_mcmahon
That's what I THOUGHT was supposed to happen, based on an article I found with Five Steps to troubleshooting "Authorization Required" pages. But the Guest profiles don't appear as options, searches don't reveal them, and Developer Support at Salesforce told me (after a lengthy side conversation with someone else) that Guest profiles are not available to debugging. Or at least I think that's what he was saying....
ForcepowerForcepower

Michael,

That is puzzling. Which SF edition are you on? It should be there for Enterprise Edition and Unlimited for sure. Also are you logged on as a Sys Admin?

Ram

michael_mcmahonmichael_mcmahon

Enterprise, in our Production org.

 

I suspect there may have been a change in that they show error messages for guests at the bottom of the page rather than in a remote log.  Keep reading....

 

I just tried adding a new page that is more complex than the Hello World page, but without using the code I used for the other pages, and got the same Auth Required error page.

 

I suspect it has something to do with this stuff that's going on in the URL:  http://quickops.force.com/newtest/a0U/l?retURL=%2Fnewtest%2Fapex%2FmediaList

 

which was generated by trying to visit:  http://quickops.force.com/newtest from the Site Detail page.  

 

The error is, again, 'Page not allowed for profile:/newtest/a0U/I'

 

newtest is the name of the Site and mediaList is the default VF page.

 

I also suspect this is tied in to my confusion about how to add "pages" to Sites.  My conversation with SF Developer Support yesterday resulted in my understanding that a force.com Site can actually only have one page associated with it, and that I need to create a new Site for every page i want to make public.  We even went so far as to discuss using AJAX as a workaround so that we wouldn't run out of pages when we hit our limit of 25 sites.

 

Further reading suggests that this is NOT true, but for the life of me I cannot understand what the public URL would be for the additional VF pages that I have made available via the declarative steps. Is there something about 

 

Thanks for sticking with me on this!

 

 

 

ForcepowerForcepower

Michael,

 

You can have a lot of pages on a single site - I'm sure there is a limit but not one that you'd encounter anytime soon. Make sure to go into Develop | Sites | Click on your site name | Click Edit  on Site VisualForce Pages.

 

You can then add your page in for the site. This will allow it to be seen by guest users hitting that site.

 

Ram

michael_mcmahonmichael_mcmahon

I understand the process of enabling pages, if you see my original post, I am able to create and make basic VF hello world pages publicly available as the default page on a Site.

 

The problems are that

 

1. anything other than the most basic VF and APEX seems to be making the page requaire authorization.

 

2. I do not understand how to provide a link on an external website to a page that is not the default page for a specific force.com Site.  I tried quickops.force.com/Sites_Name/page_name but was told yesterday that is not possible, and that's what led to the whole conversation about the limit of only being able to have 25 single-paged force.com Sites under an Enterprise license, which seemed ricidulous but which they confirmed with someone else in tech support.

 

???

 

 

ForcepowerForcepower

ok - just to reiterate, a default page for a Site automatically gets added to the pages permitted for that site. For any other page, you'll need to add them explicitly to the site through the following path. You'll see a list of available pages and a list of allowed pages. Make sure to add your available pages to the allowed list.

 

Develop | Sites | Click on your site name | Click Edit  on Site VisualForce Pages.

 

The pages are then acessible through /apex/pagename or just /pagename (if I remember correctly).

michael_mcmahonmichael_mcmahon
Yes, I understand and have done that. I have manually added additional VF
pages to each of my Sites and Site Profiles. I have ensured the Sites are
Active. I have manually made the related Object visible to each Site
Profile and editable in the relevant Object permissions.



The "if I remember correctly" part may be exactly where my problem lies, so
that's why I'm trying to find documentation, but I've read every single
document I can find on Sites and there is nothing that says, explicitly,
here is the URL structure or format for a page on a force.com Site that is
NOT the default page. There is some APEX to read it, but I want to be able
to provide links directly to the relevant pages WITHIN a force.com Site. Am
I somehow required to go through the default page FIRST, and are the Sites
pages only available as links off of the Sites default page, meaning that
you cannot directly link to a page on a Site?



And



The problems with Auth Required are happening on the default pages, too,
which are the pages that are automatically added to the VF Pages list and
which I've confirmed exist and work as apex/page_name but not as
quickops.force.com/Site_Name NOR via the link on the Sites Detail page,
neither the unsecure or the secure links that appear there, both generate
the same Auth Required and login error.
ForcepowerForcepower

ok - cool. Does your site need a logon to view its pages? It appears that you have this turned on.

 

Try going into this URL and logging on - you'll need an id that's enabled for the customer portal you have associated with your site. If you don't have one, just create a new contact with your own email id and enable it for the portal.

Here's your logon URL:

http://quickops.force.com/newtest/SiteLogin

 

Once you login, you can hit the other pages.

 

They should be accessible as

http://quickops.force.com/newtest/apex/<pagename>

 

Depending on the user profile that is enabled for your portal, make sure it is enabled to view these pages. Otherwise you'll get the Not Authorized page.

 

Ram

michael_mcmahonmichael_mcmahon
Okay, I'm not insane. Here's the latest from SF Dev Support:



I tried creating a Site in my Dev Org and I am also getting the same error.

But, the VF pages are enabled and the permissions are also granted.

However, I am still investigating on the issue and will provide you my
updates.



Thanks for all your help yesterday Ram.
ForcepowerForcepower

No problem, Michael. If you have some screenshots of your settings etc, shoot them over -  that might help. Otherwise, hopefully SF Dev Support gets back to you with some progress soon.

 

Ram

michael_mcmahonmichael_mcmahon

Just to close out my threadjack - it turned out that I was trying to display standard views that require authentication, I just need to build out VF pages rather than use standard views.  Unfortunately, I wasted two weeks because the first four people who worked on this in Premier+ Support for two full weeks could only tell me they replicated the problem!

 

Thanks for the help, especially Ram@Rcepower.

 

 

ForcepowerForcepower

Michael,

 

Glad you're finally seeing some progress. Hope it goes smoother with the rest of it.

 

Take care,

Ram

Jennifer GonzalesJennifer Gonzales
I have taken the liberty of supplementing supplementary visualforce (VF) pages to every one of my Sites and Site (https://cncrouterhub.com/best-cnc-router/) Profiles manually. To guarantee the activity of the Sites, I have personally made certain that they are active. Likewise, I have manually granted the necessary access to each Site Profile, allowing them to view and edit the pertinent Object permissions.