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
mmccauleymmccauley 

Set Value of Field

I'm trying to figure out if I can show a field based on the value of another field on the same record.

 

In my object I have a field that stores the API name of the field that needs to be rendered.

 

So for example...

 

Record 1 has Field__c has a value of Num_of_Users__c

 

Record 2 has Field__c has a value of Total_Spend__c

 

How can I create 1 line in a visualforce page that dynamically displays a input field where the value is that of Field__c?

 

<apex:inputField value="Result from Field__c" />

 

Thanks in advance!

Mark

bob_buzzardbob_buzzard

I'm not sure I quite understand the question - are you trying to use the value from Field__c as the starting value for an input on another field?

mmccauleymmccauley

Bob,

Yes you are correct.

 

bob_buzzardbob_buzzard

So much depends on your exact situation, but the way I'd be tempted to handle it is to copy the value from field__c to other_field__c in the constructor of an extension controller, and then bind the input field to other_field__c as normal.