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
MattymooMattymoo 

How do you default a field on a force.com Sites page

Hello

I'd like to gather customer feedback using a Sites.

I have a button on contact that generates an email with a link to the site.

The feedback is stored against a custom object. This is all working fine.

I need that custom object record to link back to the contact.

 

I can pass the contact ID to Site from with in the URL

http://cambridge.prelive.cs13.force.com/AcademicFeedback?ContactId=0032000000lv5LKAAY

I have coded an VF extension class that gets the ID 

 

I just can't figure out how/when to apply this id to the custom record. (or to the VF page)

I can't even get a text field to default!!!!

 

I guess the generic question is how do you default a value on a Sites VF page.

Hellllppp! :-)

 

public class FeedbackExt
{
   private ApexPages.StandardController stdCtrl;

   public Academic_Customer_Feedback__c controlledRecord;

   public FeedbackExt(ApexPages.StandardController std)
   {
      this.controlledRecord = (Academic_Customer_Feedback__c)std.getRecord();
     
      String idsParam = ApexPages.currentPage().getParameters().get('ContactId');
      this.controlledRecord.Contact__c = idsParam; // this field is not defaulting!!
      this.controlledRecord.Module_Name__c = 'PLEASE DEFAULT'; // this field is not defaulting!!
     
      stdCtrl=std;
   }

   public PageReference save()
   {
 
      stdCtrl.save();
      return Page.thanks;
   }
}

 

 

<apex:page standardController="Academic_Customer_Feedback__c" extensions="FeedbackExt" standardStylesheets="{!if($CurrentPage.parameters.css == 'std',true,false)}" showHeader="{!if($CurrentPage.parameters.css == 'std',true,false)}" >
        <apex:sectionHeader title="{!$ObjectType.Academic_Customer_Feedback__c.label} Edit" subtitle="New {!$ObjectType.Academic_Customer_Feedback__c.name}"/>
        <apex:form >
        <apex:pageBlock title="{!$ObjectType.Academic_Customer_Feedback__c.label} Edit" mode="edit">
                <apex:pageBlockButtons >
                        <apex:commandButton action="{!save}" value="Save"/>
                        <apex:commandButton action="{!cancel}" value="Cancel"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection showHeader="true" title="Customer Details" columns="2">
                        <apex:pageBlockSectionItem >
                                <apex:outputLabel value="Academic Customer Feedback Owner"/>
                                <apex:outputText value="{!Academic_Customer_Feedback__c.Owner.Name}"/>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Opportunity__c}"/>
                        <apex:pageBlockSectionItem />
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Contact__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="1. Course Details" columns="1">
                        <apex:inputField value="{!controlledRecord.Module_Name__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Module_Code__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Level_of_Module__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Number_of_Students__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Module_Start_Date__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Other_Colleagues_involved_in_decision__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Current_textbook_s_in_use__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Local_BookSeller_s__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Your_Email__c}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="2. Your Feedback" columns="2">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Adopted_main_text__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Recommended_background_reading__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Adopted_one_of_two_main_text__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Not_adopted__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Recommended_one_of_several_texts__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="false" columns="1">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Why_are_you_adopting_the_book__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.If_not_adopting_then_why__c}"/>
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Any_Other_Suggestions_for_Improvement__c}"/>
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="3. More Information" columns="2">
                        <apex:inputField value="{!Academic_Customer_Feedback__c.What_else_can_Cambridge_do_for_you__c}"/>
                        <apex:pageBlockSectionItem />
                        <apex:inputField value="{!Academic_Customer_Feedback__c.Receive_information_about_related_titles__c}"/>
                        <apex:pageBlockSectionItem />
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="Information" columns="2">
                </apex:pageBlockSection>
                <apex:pageBlockSection showHeader="true" title="System Information" columns="2">
                </apex:pageBlockSection>
        </apex:pageBlock>
        </apex:form>
</apex:page>