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
Kamran-RaoKamran-Rao 

Get Hidden Field Value in Apex Class

I have an <apex:fieldHidden id="abc" /> on my VF form. I set a value in this field on onSubmit of form. But I am unable to get to way to get this value in my apex class.

 

Any help please.

 

Regards,
Rao

Best Answer chosen by Admin (Salesforce Developers) 
ShamSham

Bind the value of hidden field with a property on controller

 

<apex:hidden value="{!hiddenValue}" />

 

 

public Controller() {

  

   public string hiddenValue {get;set;}

}

All Answers

ShamSham

Bind the value of hidden field with a property on controller

 

<apex:hidden value="{!hiddenValue}" />

 

 

public Controller() {

  

   public string hiddenValue {get;set;}

}

This was selected as the best answer
Kamran-RaoKamran-Rao

Thanks Sham, Issue resolved.

 

Here goes the precise code:

 

<apex:page controller="TestControllerDev" showHeader="false" id="testC"> <apex:form id="pixelReqForm"> <apex:inputHidden id="txtURL" value="{!hiddenField}"/> </apex:form> </apex:page> Controller: ------------ public class TestControllerDev { private String hiddenField = 'TestValue'; public String getHiddenField() { return hiddenField; } public void setHiddenField(String data) { hiddenField = data; } }

 

Jesse WolffJesse Wolff
Is "hiddenField" in your apex:inputHidden a dummy reference to a field on your custom object?

I've added the following line to my visualforce page, and now am trying to work out your controller code to work for my use case (I want the Invoice_Internal_Id__c to populate a return URL on a save action.
<apex:inputHidden id="inv" value="{!Invoice__c.Invoice_Internal_ID__c}" />
Jesse WolffJesse Wolff
I realize how old this is, but if anyone can answer I would be appreciative.  I have added the following to my controller APEX and receive the error:
Formula Expression is required on the action attributes. 
 
private String inv = 'a3O1D000000Ct9B';
    public String getinv() {
    return inv;
    }
    
    public void setinv(String data){
    inv = data; }

    public PageReference saveAndfinito(){
    scMain.save();
    PageReference Invoice = new PageReference('apex/newInvoicefromWOwithinvoiceline?id=' + inv);
    return Invoice;
        
    }