You need to sign in to do that
Don't have an account?
Debendra Ray 8
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, List has no rows for assignment to SObject: [] while inserting Quote
Hi All,
I'm getting the following error while inserting quote in a test class :
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, List has no rows for assignment to SObject: []
Please find the test class appended herewith :
@istest(SeeAllData=true) private class TestSubmitforQuoteApproval { static testmethod void test() { Test.startTest(); //Account acc = [select Id from Account limit 1]; Opportunity oppr = new Opportunity(); //oppr.AccountId = acc.ID; oppr.Annual_Contract_Value_ACV__c = 111; oppr.BU__c = 'MJ'; oppr.CloseDate = Date.today(); oppr.Contract_Opportunity_Estimate_CoE__c = 111; oppr.Total_Contract_Value_TCV__c = 111; oppr.Name = 'SubmitforQuoteApproval'; oppr.StageName = 'Prospecting'; oppr.Date_on_Opportunity_Prospecting_Stage__c = Date.today(); //oppr.UpdatedForReminderToApprover__c = Date.today(); insert oppr; Quote quot = new Quote (); quot.Name = 'TestPropForSandbox2016-1'; //quot.Status ='Draft'; quot.OpportunityId = oppr.id ; insert quot;
}
}
Any help towards resolving this issue will be much appreciated
Thanks & Rgards,
Debendra Ray
I'm getting the following error while inserting quote in a test class :
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, List has no rows for assignment to SObject: []
Please find the test class appended herewith :
@istest(SeeAllData=true) private class TestSubmitforQuoteApproval { static testmethod void test() { Test.startTest(); //Account acc = [select Id from Account limit 1]; Opportunity oppr = new Opportunity(); //oppr.AccountId = acc.ID; oppr.Annual_Contract_Value_ACV__c = 111; oppr.BU__c = 'MJ'; oppr.CloseDate = Date.today(); oppr.Contract_Opportunity_Estimate_CoE__c = 111; oppr.Total_Contract_Value_TCV__c = 111; oppr.Name = 'SubmitforQuoteApproval'; oppr.StageName = 'Prospecting'; oppr.Date_on_Opportunity_Prospecting_Stage__c = Date.today(); //oppr.UpdatedForReminderToApprover__c = Date.today(); insert oppr; Quote quot = new Quote (); quot.Name = 'TestPropForSandbox2016-1'; //quot.Status ='Draft'; quot.OpportunityId = oppr.id ; insert quot;
}
}
Any help towards resolving this issue will be much appreciated
Thanks & Rgards,
Debendra Ray
Further to the above email, I've a lookup field Account in the Quote Object - I believe , failure to assign the Account Lookup value to the Quote is resulting in the above error. However, please could someone show me how to assign the Account Lookup Value to the Quote Object in the Apex Test Class.
An early response on this will be much appreciated.
Thanks & Regards,
Debendra
There a 2 errors as i can make out from your question:
Let me know if it helps.
Regards
Medhya Mahajan
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, error: []
Class.AccountProcessorTest.TestAccountProcessorTest: line 6, column 1
What is my mistake I dont know,Anyone correct my mistake
public class AccountProcessorTest {
public static testmethod void TestAccountProcessorTest(){
Account a = new Account();
a.Name = 'Test Account';
Insert a;
system.debug('account a :'+a.id);
Contact cont = New Contact();
cont.FirstName ='Ankit';
cont.LastName ='Avula';
cont.AccountId = a.Id;
Insert cont;
system.debug('contact cont :' +cont.id);
List<Id> accIds = new List<Id>();
accIds.add(a.Id);
Test.startTest();
AccountProcessor.countContacts(accIds);
Test.stopTest();
Account ACC = [select Number_of_Contacts__c from Account where id = :a.id LIMIT 1];
System.assertEquals(ACC.Number_of_Contacts__c, 1);
}