You need to sign in to do that
Don't have an account?
Javagal
help with Test Class
I need help with test class for the below trigger. some one please help me. Many thanks guys.
trigger UpdateCR on Case (before update) { Map<String, Schema.RecordTypeInfo > caseRecordTypes = Case.sObjectType.getDescribe().getRecordTypeInfosByName(); Id recordTypeId = caseRecordTypes.get('US Cases Locked RT').getRecordTypeId(); for ( Case c : Trigger.new) { if (c.CF_Tracking__c != null ){ if( c.Status == 'Closed') { c.RecordTypeId = recordTypeId; } } } }
List<RecordType> oppRecTypeList = [Select Name, Id From RecordType
where sObjectType='Opportunity' and isActive=true];
Map<String,String> oppRecTypeMap = new Map<String,String>{};
for(RecordType rt: oppRecTypeList)
oppRecTypeMap.put(rt.Id,rt.Name);
I used this in my code as follows. Note that newOpportunity is one of the opportunities being processed by the trigger.
if (oppRecTypeMap.get(newOpportunity.RecordTypeId) != NULL) {
oppRecordType = oppRecTypeMap.get(newOpportunity.RecordTypeId);
} else {
oppRecordType = 'Single Donation';
}
(I believe I had to do this because we had an automated process that would occassionally try to insert an opportunity that didn't have a record type ID. If that's possible. :) I don't remember for sure. But the code works now.)
Case c1 = new <Case>();
c1. ... [set various parameters]
insert c1;
c1. ... [set parameters to match your conditions]
update c1;
Let me know if something like that works. I'm pretty new to this myself. :)