Need pro's help. Below are my code snippets. This is what I have tried I have initialized the object Event_Request__c {get; set;} in my controller class. I have created a public method to update the Event Request record. On saving, the VF page and Class both are being saved successfully. However, I am not any data. Please advise what is it that am missing.

Input Field and Commandbutton on VF page:

Input field

<div class="form-group">
     <label for="WBS">WBS:</label>
     <input type="text" placeholder="WBS" class="form-control" id="{WBS}" />

SubmitRequest Button

    <apex:commandButton action="{!updateEventRequest}" reRender="pageId" id="SubmitRequest" value="Submit Request" >  
        <apex:param id="InputWBS" value="{WBS}"></apex:param>

Controller class method

   public PageReference updateEventRequest() {
         sEventRequest.WBS__c= ApexPages.currentPage().getParameters().get('WBS');   
         System.debug('The id for update is WBS = ' + sEventRequest.WBS__c);
          update sEventRequest;
          return null;
  • Noticed that submit request button code didnt show up so posting again: <apex:form> <apex:commandButton action="{!updateEventRequest}" reRender="pageId" id="SubmitRequest" value="Submit Request"> <apex:param id="InputWBS" value="{WBS}"> </apex:param> </apex:commandButton> </apex:form> – Ng H Feb 8 '16 at 11:32

To pass data to Apex from VisualForce you should use apex:input* tag, for example, apex:input,apex:inputText or apex:inputField.

in your case, if you want to make that text input, you need to use

<apex:inputText  html-placeholder="WBS" styleClass="form-control" value="{!WBS}" />

If you want to do a lookup:

In both cases ensure that properties have public set, in first case ensure that you have doc-type set. Also, you need to wrap it to apex:form to send data to apex controller.

Here you can find more information about how to use that input: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_input.htm

Update: After comment reread Visualforce page part:

     <apex:inputText  html-placeholder="WBS" styleClass="form-control" value="{!WBS}" />
    <apex:commandButton action="{!updateEventRequest}" reRender="pageId" id="SubmitRequest" value="Submit Request" />  

Apex Controller part:

Define property WBS as string

public String WBS{get;set;}

And if you want to use standard SF lookup window -- just use

But ensure that sEventRequest is defined as

public <some type> sEventRequest{get;set;}

and it is initiated in constructor (i.e. not null).

  • Hi Kurunve, Thanks for your reply. Can you please advise how to set the properties to public and how to set the doc type. – Ng H Feb 8 '16 at 11:43
  • As when I try using the {!WBS} it gives me an unknown property error! Thanks again for your help! – Ng H Feb 8 '16 at 11:44
  • The sEventRequest has already been instantiated as: – Ng H Feb 8 '16 at 12:09
  • @user4435979 so, do you still have any issues? – kurunve Feb 8 '16 at 12:10
  • The sEventRequest instantiation: public EventRequest__c sEventRequest {get; set;} sEventRequest initialisation in Controller/Util: sEventRequest = Utils.getEventRequest(sCampaign.ID); Util Class: public static EventRequest__c sEventRequest {get; set;} public static EventRequest__c getEventRequest(string sCampaignId){ sEventRequest = [select Name, Quantity__c,SelfServ_Link__c,Status__c,Tickets_Remaining__c,Total_Attending__c,WBS__c from EventRequest__c where Event__c=:sCampaign.Id limit 1]; return sEventRequest; } – Ng H Feb 8 '16 at 12:15

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.