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

how to access apex ui fields in customcontroller

Here is my method in customController:


public PageReference AddRecord()



Here is my pageblocksection in my page:


<apex:pageblockSection columns="2" Title="Donation Details" >
<apex:inputField value="{!Donation.Contact__c}"/>
<apex:inputField value="{!Donation.Donation_Amount__c}"/>
<apex:inputField value="{!Donation.Donation_Date__c}"/>
<apex:inputField id="state" value="{!Donation.Donation_State__c}"/>



I would like to access the inputField with id=state in my customcontroller , how to do this?


Please help.




Deepak Kumar ShyoranDeepak Kumar Shyoran

Hi saisai,


If I get your requirement properly then you nees to access the Donation.Donation_State__c in your controller you can perform it in following ways.


You just create a public property with get set in your controller like.


public String state {get;set;}


Now on visual forcepage you need to write a javascript function which call to a apex:action function in following way.

<apex:actionFunction name="stateInitilization" reRender = "none" >

<apex:param name="param1" value="" assignTo ="{!state}" />

<apex:actionfunction />


<apex:inputField id="state" value="{!Donation.Donation_State__c}" />


   var v= "{!Donation.Donation_State__c}"




Hopefully by using above technique you will get Donation_State__c value in your controller state varible


Don't forget to give Kudos if this post helped you.

Mark my answer as a solution to your question if it solve your problem.




Choudhary Deepak Shyoran

Salesforce Developer




There is no need to access this Donation_state__c field by id you can just use it without id. becuase you alreadt binded Donation reference in Class and Page. 


Please let me know in case of query we are not getting properly