Reply
Regular Contributor
ramya1
Posts: 27
0

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 

 

 

Super Contributor
kiran_mutturu
Posts: 1,175
0

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

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

o.CloseDate=system.today();
Certified Force.com Developer, Certified Administrator, Certified Service cloud consultant

My Blog

Kiran
Regular Contributor
ramya1
Posts: 27
0

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

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]

Super Contributor
kiran_mutturu
Posts: 1,175
0

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

[ Edited ]

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

Certified Force.com Developer, Certified Administrator, Certified Service cloud consultant

My Blog

Kiran