2

I have 2 visualforce pages :

  • refugee_main_tfi
  • refugee_dash_tfi

To make them available to public ( without salesforce login ) I have created a site and added these pages through "Enable Visualforce Page Access" to site.

now when i access the site I face two issues: http://tfifellows-refugeetransition.cs17.force.com/tfihome

  1. my static resources are not loaded. ( logo image is missing)
  2. The second page after redirect from the first gives me "Authorization error" --> http://tfifellows-refugeetransition.cs17.force.com/tfihome/refugee_dash_tfi?Id=003g000000X2CwhAAF ( this is how the url looks after redirect)

This is snippet of my controller for first page that redirects to the second. First page is accessible but not the second (authorization error)

// if validated everything, redirect to detail page for found HBT ID
            String strNewUrl = '/apex/refugee_dash_tfi?Id=' + lstContacts[0].Id;
            PageReference pr = new PageReference (strNewUrl);
            pr.setRedirect (true);
            return pr;

I am new to salesforce and trying to build a site from where contacts can edit objects related to them. Any guidance will be highly appreciated.

5
  • 2
    Static Resources need to be Public to be used on a site. Also, does the guest user profile have access to the class if any and the contact in question. If you can view the pages within salesforce /apex/pagename>parameters then it is an access issue
    – Eric
    Commented Jul 17, 2015 at 17:16
  • 1
    By building the PageReference from a String you are missing the site name prefix that is normally used instead of "apex". I assume (but don't have an example to hand) that if you used PageReference pr = Page.refugee_dash_tfi; instead the platform would take care of that for you. You can add parameters via the getParameters map.
    – Keith C
    Commented Jul 17, 2015 at 17:49
  • @KeithC Thanks for your reply , i did that but it doesnt make difference in authorization error : Thanks for the comment though , I did learn the right way to do it :) Commented Jul 17, 2015 at 18:05
  • @Eric thanks for the reply : so after reading help.salesforce.com/apex/… so as I understand : when i created the site : there was an automatic guest user created , and i can modify the permissions of this user via sites-> public access setting. but i dont see anything specific there to give access to . I did make the tab visible and Standard Object Permissions --> ticked create and read in contacts (these are the only options) Commented Jul 17, 2015 at 18:05
  • Also after reading this: help.salesforce.com/… I created a group with guest user and gave access to contacts. But things are still not working. Do you mind sharing documents that i need to refer to understand this process. Thanks a lot. Commented Jul 17, 2015 at 18:05

1 Answer 1

1

Well I am posting this answer so that if someone novice like me is stuck ,it might help :

I posted two issues:
Issue 1: my static resources are not loaded. ( logo image is missing) --> was solved by the comment from @Eric I simply needed to make the static resaurces public.

Issue 2: "Authorization error" It turns out that guest user ( a user without login ) for sites can not edit "Standard Objects" although they can edit Custom objects . Since i was using standardController I was getting the authorization error. ref : https://developer.salesforce.com/page/Authenticating_Users_on_Force.com_Sites (The last 2 paragraphs before the "custom portal topic") .

The work around has been explained very nicely in this reply here by @Peter Knolle :

Workarounds for Sites page to update standard object?

You must log in to answer this question.

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