0

I have a Visualforce page which successfully submits a form. But I made a public facing page using "Sites" in Setup and that one is failing. In the VF page I am taking values from a visible form and plugging them into a hidden apex form (because apex forms are ugly).

When I look at the visualforce page in my org (at the link https://tractionondemand--bttom--c.cs62.visual.force.com/apex/CSATSurvey?pid=a8q5C000000L2m3QAC&cid=0035C00000G4n14QAB) the apex form is generating. I can tell because I temporarily took off the "hidden" class. But on the public site (which uses that same VF page) the apex form is not showing and I get an error when trying to submit.

VF page (works properly):

enter image description here

Public Site (does not display the apex:form):

enter image description here

VF page form code:

<apex:form styleClass="">
                    <!-- Values will be copied from prettier form above -->
                    <apex:inputText id="couldDoBetter" value="{!survey.What_can_Traction_do_even_better__c}"/>
                    <apex:inputText id="didReallyWell" value="{!survey.What_did_traction_do_really_well__c}"/>
                    <apex:inputText id="additionalComments" value="{!survey.Additional_Comments__c}"/>

                    <apex:inputText id="recommendChance" value="{!survey.Likelihood_of_recommending_Traction__c}"/>

                    <apex:inputText id="documentation" value="{!survey.Documentation_was_clear_and_thorough__c}"/>
                    <apex:inputText id="objectiveAchievement" value="{!survey.The_objectives_were_met__c}"/>
                    <apex:inputText id="objectiveClarity" value="{!survey.The_objectives_were_clearly_defined__c}"/>
                    <apex:inputText id="teamResponsiveness" value="{!survey.Inquires_were_answered_in_timely_manner__c}"/>
                    <apex:inputText id="training" value="{!survey.User_training_was_effective__c}"/>
                    <apex:inputText id="communication" value="{!survey.The_communication_was_consistent__c}"/>

                    <!-- Filled in from url parameters -->
                    <apex:inputText id="projectId" value="{!survey.Project__c}"></apex:inputText>
                    <apex:inputText id="contactId" value="{!survey.Recipient__c}"></apex:inputText>

                    <!-- Used to submit hidden form to salesforce -->
                    <apex:commandButton id="salesforceSubmitButton" action="{!save}" value="Save"/>
                    <script>
                        console.log('form loaded...');
                        // Make the hidden form fields and button accessable by javascript (IDs are generated)
                        var additionalCommentsFieldId = '{!$Component.additionalComments}';
                        console.log('additionalCommentsFieldId: ' + additionalCommentsFieldId);
                        var couldDoBetterFieldId = '{!$Component.couldDoBetter}';
                        var didReallyWellFieldId = '{!$Component.didReallyWell}';

                        var recommendChanceFieldId = '{!$Component.recommendChance}';

                        var documentationFieldId = '{!$Component.documentation}';
                        var objectiveAchievementFieldId = '{!$Component.objectiveAchievement}';
                        var objectiveClarityFieldId = '{!$Component.objectiveClarity}';
                        var teamResponsivenessFieldId = '{!$Component.teamResponsiveness}';
                        var trainingFieldId = '{!$Component.training}';
                        var communicationFieldId = '{!$Component.communication}';
                        var salesforceSubmitButtonId = '{!$Component.salesforceSubmitButton}'
                    </script>

                </apex:form>
  • 1
    Are you using a standard controller on your VF page? If yes, then you may like to verify if the User (profile) accessing the page on the Site has necessary FLS permissions assigned for the Object being referenced in your VF page. – Jayant Das Nov 13 '18 at 22:55
  • @JayantDas Oh good point! That could be the problem. I looked at the FLS for the fields i'm using, but I'm not seeing how to make this field accessible to EVERYONE (even people without a Salesforce account). I think that is what I need because it's a public-facing site. Do you know how to give read access to all public users? – tom_12321 Nov 13 '18 at 23:15
  • 1
    go to Sites, click on the site's label (not on "Edit") and then click on "Public Access Settings". That's where you specify what the public site guest user can do. – Sebastian Kessel Nov 13 '18 at 23:59
  • @JayantDas and Sebastian was right, when I added the FLS by following Sebastion's suggestions it worked. Thanks Guys! – tom_12321 Nov 14 '18 at 18:31
0

What you need here is to provide access to the Public Users on your Site by configuring the Public Access Settings for Salesforce Sites.

Public access settings control what public users can do on each Salesforce Sites site. To set the public access settings for your site:

  1. From Setup, enter Sites in the Quick Find box, then select Sites.
  2. Click the name of the site you want to control.
  3. Click Public Access Settings to open the Profile page for your site profile.

Once you are in the profile page, you need to set the access to respective components as you would do for a regular profile. Below are the configurations you need here:

  • Enable the Visualforce page
  • Set the Permissions to access the respective objects and fields

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.