You need to sign in to do that
Don't have an account?
kumar.fdc81.3902978579608325E12
System.TypeException: Invalid id value for this SObject type Test classe error
Hi all,
I written one trigger and test class getting this error.
System.TypeException: Invalid id value for this SObject type
Trigger:-
----------
trigger EscalateCase on Escalation__c (after update) {
IF(Trigger.size > 1){return;}
IF(Trigger.new[0].Reason_For_Escalation__c == null || Trigger.new[0].Escalation_Comments__c == null || Trigger.new[0].Escalate_To_Management__c == false || Trigger.new[0].Case__c == null){return;}
Case c = new case(ID = trigger.new[0].Case__c, Escalate_To_Management__c = trigger.new[0].Escalate_To_Management__c, Reason_For_Escalation__c = trigger.new[0].Reason_For_Escalation__c, Escalation_Comments__c = trigger.new[0].Escalation_Comments__c);
update c;
}
Test class:-
--------------
@isTest
private class EscalateCaseTestClass{
@isTest static void Esc(){
Account a = new Account(Name='ContractBookingPeriodProcessingTest',Geography__c='TestGeography',
Territory_Id__c='TestTerritory',
Territory_Overlay__c='TestTerritoryOverlay',Renewals_Team__c='TestRenewalsTeam',
Renewals_Account_Manager__c='TestRenewalsAccountManager');
insert a;
Contract c = new Contract(AccountId=a.id,Number_of_Booking_Periods_Records__c = 0, Number_of_Booking_Periods__c = 1,
Status='Create', Finance_Charges__c ='0.5%',
Contract_Term_Start_Date__c=date.valueOf('2013-01-01'),
Contract_Term_End_Date__c=date.valueOf('2099-12-31')
);
insert c;
Case case1 = new case(Id=a.id,Escalate_To_Management__c =true,Reason_For_Escalation__c = 'TestReason' ,Escalation_Comments__c = 'TestEscalation' );
insert case1;
case1.Reason_For_Escalation__c = 'TestReasonForEscalation';
case1.Escalation_Comments__c = 'TestEscalationComments';
update case1;
}
}
Thanks
kumar
I written one trigger and test class getting this error.
System.TypeException: Invalid id value for this SObject type
Trigger:-
----------
trigger EscalateCase on Escalation__c (after update) {
IF(Trigger.size > 1){return;}
IF(Trigger.new[0].Reason_For_Escalation__c == null || Trigger.new[0].Escalation_Comments__c == null || Trigger.new[0].Escalate_To_Management__c == false || Trigger.new[0].Case__c == null){return;}
Case c = new case(ID = trigger.new[0].Case__c, Escalate_To_Management__c = trigger.new[0].Escalate_To_Management__c, Reason_For_Escalation__c = trigger.new[0].Reason_For_Escalation__c, Escalation_Comments__c = trigger.new[0].Escalation_Comments__c);
update c;
}
Test class:-
--------------
@isTest
private class EscalateCaseTestClass{
@isTest static void Esc(){
Account a = new Account(Name='ContractBookingPeriodProcessingTest',Geography__c='TestGeography',
Territory_Id__c='TestTerritory',
Territory_Overlay__c='TestTerritoryOverlay',Renewals_Team__c='TestRenewalsTeam',
Renewals_Account_Manager__c='TestRenewalsAccountManager');
insert a;
Contract c = new Contract(AccountId=a.id,Number_of_Booking_Periods_Records__c = 0, Number_of_Booking_Periods__c = 1,
Status='Create', Finance_Charges__c ='0.5%',
Contract_Term_Start_Date__c=date.valueOf('2013-01-01'),
Contract_Term_End_Date__c=date.valueOf('2099-12-31')
);
insert c;
Case case1 = new case(Id=a.id,Escalate_To_Management__c =true,Reason_For_Escalation__c = 'TestReason' ,Escalation_Comments__c = 'TestEscalation' );
insert case1;
case1.Reason_For_Escalation__c = 'TestReasonForEscalation';
case1.Escalation_Comments__c = 'TestEscalationComments';
update case1;
}
}
Thanks
kumar
Check filter criteria on case's account Field
To Check filter criteria follow these steps :
Setpup -> Case -> Fields -> Account Name (Field) -> Lookup Filter
According to this condition put data in account record than assign it to case.
All Answers
You are putting account id in case Id that is invalid.Also to cover your trigger you need to create Escalation__c record and than update it.
Like :
Regards
Subhash
i written as per an=bove code i am getting this error.
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, The Account you are searching for does not exist or is not a current customer.: [AccountId]
Test Class:-
@isTest
private class EscalateCaseTestClass{
@isTest static void Esc(){
Account a = new Account(Name='PipelineChangeTest',Geography__c='TestGeography',Territory_Id__c='TestTerritory',
Territory_Overlay__c='TestTerritoryOverlay',Renewals_Team__c='TestRenewalsTeam',Renewals_Account_Manager__c='TestRenewalsAccountManager');
insert a;
Contact c = new Contact(AccountId=a.id,LastName='Test',Job_Function__c='TestJobFunction',Department__c='TestDepartment');
insert c;
Case case1 = new case(AccountId=a.id,ContactId=c.id);
insert case1;
//Inset Escalation__c
Escalation__c esc = new Escalation__c(Case__c = case1.Id, Reason_For_Escalation__c = 'Test', Escalation_Comments__c = 'Test', Escalate_To_Management__c = true);
insert esc;
//update
update esc;
}
}
Thanks
kumar
Class.EscalateCaseTestClass.Esc: line 13, column 1
Thanks
kumar
Thanks
I Cecked Validation rules, Not available any Validation based on ID.
Thanks
kumar
Check filter criteria on case's account Field
To Check filter criteria follow these steps :
Setpup -> Case -> Fields -> Account Name (Field) -> Lookup Filter
According to this condition put data in account record than assign it to case.