0

I have a custom field of date in opportunity . i need to display the date in visualforce page using inputfield, so that i can edit and save the form later. for that i am doing

visualforce page

     <apex:inputfield value="{!oppList.date__c}"/> 

controller

 public class SurveyFormController 
 {
 public string opportunityId{get;set;}
 public Opportunity oppList{get;set;}

 public SurveyFormController(ApexPages.StandardController stdController) 
 {
    opportunityId = Apexpages.currentPage().getParameters().get('oppId');
    this.oppList=[select id,Date__c from opportunity where id=:opportunityId];        
 }
}

I am able to get the datepicket in page but i am unable to prepopulate the value . could any one guide me up

  • Try appending [0] at the end of your query. i.e.[select id,Date__c from opportunity where id=:opportunityId][0]; – highfive Sep 3 '14 at 6:03
0

The only cause I can see is that the Date__c field must be null to start with.

You can set that after the object has been queried when it is null to whatever default is appropriate:

public SurveyFormController(ApexPages.StandardController stdController) 
{
    opportunityId = Apexpages.currentPage().getParameters().get('oppId');
    oppList = [select id,Date__c from opportunity where id=:opportunityId];
    if (oppList.Date__c == null) {
        opList.Date__c = Date.today();
    }
}

and that value will be presented in the Visualforce.

|improve this answer|||||

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.