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
ramya1ramya1 

Err When creating opportunity - Required fields are missing: [CloseDate]

Hi...

 

I have an Issue in a Test case....

 

While inserting the Opportunity....I used the ClosedDate Field...But am getting Error as 

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloseDate]: [CloseDate]

 

Test Case that i Have Used is : 

 

@isTest
private class NewDisbursementMemo_TC
{
static testMethod void test()
{

Branch__c b = new Branch__c();
b.name = 'qwe';
insert b;

Account a = new account();
a.name='asd';
insert a;

Opportunity o=new Opportunity ();
o.Name='qwer';
o.CloseDate=date.ValueOf('2011-09-21');
o.StageName='Prospecting';
o.Branch__c=b.id;
o.AccountId = a.id;
insert o;  // Getting Error at this line

Disbursement__c d= new Disbursement__c();
d.Loan__c=o.id;
insert d;

ApexPages.currentPage().getParameters().put('id', d.id);
ApexPages.StandardController con = new ApexPages.StandardController(d);
NewDisbursementMemo ext = new NewDisbursementMemo(con);

}
}

 

 

Thanks in Advance 

 

 

kiranmutturukiranmutturu
o.CloseDate=date.ValueOf('2011-09-21'); change this line to

o.CloseDate=system.today();
ramya1ramya1

Thanks for your reply...

 

I Used     o.CloseDate=system.today();

 

But Still am Getting the same error.. as System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloseDate]: [CloseDate]

kiranmutturukiranmutturu

is there any opportunity triggers that may fire in the insert call of the opportunity ...