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

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

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .