• dza84
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi all,

 

I have an Apex page which only renders certain pageblock sections according to the user's selection.

 

In some cases, required fields will be hidden (per the below code snippet).

 

<apex:page standardController="opportunity" extensions="OppExt">

=== other code goes here == <apex:inputHidden value="{!opportunity.name}" id="name"/> <apex:inputHidden value="{!opportunity.Channel__c}" id="channel"/> <apex:inputHidden value="{!opportunity.closedate}" id="closedate"/> <apex:inputHidden value="{!opportunity.stagename}" id="stagename"/> <apex:inputHidden value="{!opportunity.probability}" id="probability"/>

== rest of my code goes here ==

</apex:page>

 

In order to be able to save the record, I need to ensure that required fields are populated with something in the background (ie a default value). So I do this via a controller extension.

 

However, the only success I've had is with setting a default value for the opportunity name. I've had no luck with the other fields.

 

public class OppExt {

    public OppExt(ApexPages.StandardController controller)
    {Opportunity opp = (Opportunity) controller.getRecord(); opp.name = 'Default value goes here';}

}

 

Can anyone help me with assigning default values to the remaining hidden fields (channel, stagename, closedate, probability)?

 

- Chris

 

  • February 18, 2013
  • Like
  • 0

Hi all,

 

I have an Apex page which only renders certain pageblock sections according to the user's selection.

 

In some cases, required fields will be hidden (per the below code snippet).

 

<apex:page standardController="opportunity" extensions="OppExt">

=== other code goes here == <apex:inputHidden value="{!opportunity.name}" id="name"/> <apex:inputHidden value="{!opportunity.Channel__c}" id="channel"/> <apex:inputHidden value="{!opportunity.closedate}" id="closedate"/> <apex:inputHidden value="{!opportunity.stagename}" id="stagename"/> <apex:inputHidden value="{!opportunity.probability}" id="probability"/>

== rest of my code goes here ==

</apex:page>

 

In order to be able to save the record, I need to ensure that required fields are populated with something in the background (ie a default value). So I do this via a controller extension.

 

However, the only success I've had is with setting a default value for the opportunity name. I've had no luck with the other fields.

 

public class OppExt {

    public OppExt(ApexPages.StandardController controller)
    {Opportunity opp = (Opportunity) controller.getRecord(); opp.name = 'Default value goes here';}

}

 

Can anyone help me with assigning default values to the remaining hidden fields (channel, stagename, closedate, probability)?

 

- Chris

 

  • February 18, 2013
  • Like
  • 0