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
sfdc newbiesfdc newbie 

how to get close date in convert lead page

how to get close date in convert lead page?

here i have created a custom conert lead page.
in that i have applied the code for close date in opportunity section in vf:

<apex:pageBlockSectionItem id="oppCloseDateSection" rendered="true">
                        <apex:outputlabel for="opportunityCloseDate" value="Close Date" />
                        <apex:outputPanel styleClass="requiredInput" layout="block">
                           <apex:outputPanel styleClass="requiredBlock" layout="block" />
                            <apex:inputField id="oppCloseDate" value="{!opportunity.CloseDate}" />
                      </apex:outputPanel>
                    </apex:pageBlockSectionItem>

and in Apex class:

//If user decides to create Opportunity, insert new Opportunity
                if (!doNotCreateOpportunity) {
                    try {
                        if (opportunity.Opportunity_XXX__c == 'XXX') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'XXX'].Id;
                        else if (opportunity.Opportunity_Intergaph_XXX__c == 'YYYY) opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'YYYY'].Id;
                        else if (opportunity.Opportunity_XXX__c == 'zzzz') opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'zzzz'].Id;
                        else opportunity.RecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PPP'].Id;
                        opportunity.AccountId = account.Id;
                        opportunity.Name = opportunityName;
                        opportunity.StageName = 'Lead 0%';
                       opportunity.CloseDate = lead.Close_date__c;
                        //opportunity.XXX__c = lead.XXX__c;
                      
                        insert opportunity;
bob_buzzardbob_buzzard
What problem are you seeing?
sfdc newbiesfdc newbie
when i save it is not showing me any error but when i insert values in the opportunity and other sections in the page close date getting cleared and showing an error like close date missing.


sfdc newbiesfdc newbie
and it is required even i have created a custom field and tested in the opportunity object