You need to sign in to do that
Don't have an account?

on test class i got this error Can you pls help me.System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [AccountId]: [AccountId]
Hi All,
I am writing a test class on Entitelement . in this object we have lookupfileds to Entitlement object.
Thesre are lookup fileds
CAS_Entitlement__c,DSE_Entitlement__c,OSE_Entitlement__c.
i got this error
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [AccountId]: [AccountId]
Below is my test class and also i got error , could you please can any one help.
@istest(SeeAllData=true)
public class caseSupportPortalControllerGS_test
{
public static testMethod void caseCust()
{
case objCase=new Case(status='New',Origin='Phone',Subject='RSA',Type__c='Technical',PL_RSA_Product_Set__c='DLP',
PL_RSA_Product__c='Archer',PL_RSA_Version_Condition__c='5.3',
Issue_Type__c='SA missing csas rules',Platform__c='windows');
insert objCase;
case objCase1=new Case(status='New',Origin='Phone');
RSA_Product_Set__c objRSA=new RSA_Product_Set__c(Name='test',Type__c='Technical Support');
insert objRSA;
Account a = new Account(Name='Test01',Country__c='India',City__c='Chennai',Street__c='karapakam');
insert a;
Entitlement objEntl=new Entitlement(Name='test',Startdate=system.today(),MSSP_Account_Name__c='Test2');
insert objEntl;
Entitlement objEnt2=new Entitlement();
objEnt2.Name='test';
objEnt2.Startdate=system.today();
objEnt2.CAS_Entitlement__c=objEntl.id;
objEnt2.DSE_Entitlement__c=objEntl.id;
objEnt2.OSE_Entitlement__c=objEntl.id;
objEnt2.TAM_Entitlement__c=objEntl.id;
objEnt2.Name=a.id;
insert objEnt2;
ApexPages.currentPage().getParameters().put('caseId',objCase.Id);
ApexPages.StandardController sc = new ApexPages.StandardController(objCase);
caseCustomerSupportPortalControllerGS contr = new caseCustomerSupportPortalControllerGS(sc);
PageReference pageRef = Page.caseCustomerSupport_PortalVFGS;
Test.setCurrentPage(pageRef);
contr.getSevItems();
contr.runSearch();
contr.ArticleView();
contr.submitAttachment();
contr.NewSave();
contr.routetoProperQueue(objCase1);
contr.updateEntitlementIcons('test');
contr.CollectVersionConditionList();
contr.CollectProductSetList();
contr.CollectProductList();
}
Regrads,
VIswa
I am writing a test class on Entitelement . in this object we have lookupfileds to Entitlement object.
Thesre are lookup fileds
CAS_Entitlement__c,DSE_Entitlement__c,OSE_Entitlement__c.
i got this error
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [AccountId]: [AccountId]
Below is my test class and also i got error , could you please can any one help.
@istest(SeeAllData=true)
public class caseSupportPortalControllerGS_test
{
public static testMethod void caseCust()
{
case objCase=new Case(status='New',Origin='Phone',Subject='RSA',Type__c='Technical',PL_RSA_Product_Set__c='DLP',
PL_RSA_Product__c='Archer',PL_RSA_Version_Condition__c='5.3',
Issue_Type__c='SA missing csas rules',Platform__c='windows');
insert objCase;
case objCase1=new Case(status='New',Origin='Phone');
RSA_Product_Set__c objRSA=new RSA_Product_Set__c(Name='test',Type__c='Technical Support');
insert objRSA;
Account a = new Account(Name='Test01',Country__c='India',City__c='Chennai',Street__c='karapakam');
insert a;
Entitlement objEntl=new Entitlement(Name='test',Startdate=system.today(),MSSP_Account_Name__c='Test2');
insert objEntl;
Entitlement objEnt2=new Entitlement();
objEnt2.Name='test';
objEnt2.Startdate=system.today();
objEnt2.CAS_Entitlement__c=objEntl.id;
objEnt2.DSE_Entitlement__c=objEntl.id;
objEnt2.OSE_Entitlement__c=objEntl.id;
objEnt2.TAM_Entitlement__c=objEntl.id;
objEnt2.Name=a.id;
insert objEnt2;
ApexPages.currentPage().getParameters().put('caseId',objCase.Id);
ApexPages.StandardController sc = new ApexPages.StandardController(objCase);
caseCustomerSupportPortalControllerGS contr = new caseCustomerSupportPortalControllerGS(sc);
PageReference pageRef = Page.caseCustomerSupport_PortalVFGS;
Test.setCurrentPage(pageRef);
contr.getSevItems();
contr.runSearch();
contr.ArticleView();
contr.submitAttachment();
contr.NewSave();
contr.routetoProperQueue(objCase1);
contr.updateEntitlementIcons('test');
contr.CollectVersionConditionList();
contr.CollectProductSetList();
contr.CollectProductList();
}
Regrads,
VIswa
Let us know if this will help you
Stack TraceClass.caseSupportPortalControllerGS_test.caseCust: line 19, column 1
Entitlement objEntl=new Entitlement(Name='test',Startdate=system.today(),MSSP_Account_Name__c='Test2',AccountId=a.id);
insert objEntl;