+ Start a Discussion
SkeeterSkeeter 

trigger comparison argument must be of compatible type

I'm having issues with my trigger when I'm trying to pull 2 different record types.  I should pull either the customersupport case record type or customer_service record type for the support cases.
Comparison arguement must be of compatible types (Id,RecordType)
Any help is greatly appreciated.
 
trigger ContactSupportSurveyDates on Case (before update) {

Case[] oldvalue = trigger.old;
Case[] newvalue = trigger.new;
Integer i=0;

Map<ID,RecordType> rt_Map = New Map<ID,RecordType>([Select ID, Name From RecordType Where sObjectType = 'Case']);    
for (Case c : trigger.new)
{

if (oldvalue[i].Survey_Date__c <> newvalue[i].Survey_Date__c)
   
{

Contact t = [select Id,Last_Support_Survey_Date__c,Last_Implementation_Survey_Date__c from Contact where Id =:c.ContactId limit 1];

if (c.RecordTypeId == rt_Map.get('Customer_Service') || c.RecordTypeId == rt_Map.get('CustomerSupport')) //support case id
{ 
t.Last_Support_Survey_Date__c = c.Survey_Date__c; 
update t; 
}

if (c.RecordTypeId == rt_Map.get('Pharmacy_Implementation')) // implementation case id
{
t.Last_Implementation_Survey_Date__c = c.Implementation_Survey_Date__c;
update t;

}}}}

 
ManojjenaManojjena
Hi Lilranger,

Try with below code it will help !!
 
trigger ContactSupportSurveyDates on Case (before update) {
   List<Contact> conList=new List<Contact>();
   Map<Id,String> recTypeMap=new Map<Id,String>();
   for(RecordType rec :[Select ID, Name From RecordType Where sObjectType = 'Case']){
      recTypeMap.put(rec.Id,rec.Name);
   }
   for (Case cs : trigger.new){
      if(cs.Survey_Date__c != Trigger.oldMap.get(cs.Id).Survey_Date__c){
	     if(recTypeMap.get(cs.RecordTypeId) =='Customer_Service' || recTypeMap.get(cs.RecordTypeId) =='CustomerSupport'){
		    if(cs.Survey_Date__c != null){
			   Contact con=new Contact(Id=cs.ContactId,Last_Support_Survey_Date__c = cs.Survey_Date__c);
			   conList.add(con);
		   }
		 }if(recTypeMap.get(cs.RecordTypeId) =='Pharmacy_Implementation'){
		   if(cs.Implementation_Survey_Date__c != null){
			   Contact con=new Contact(Id=cs.ContactId,Last_Implementation_Survey_Date__c = cs.Implementation_Survey_Date__c);
			   conList.add(con);
		   }
		 }
	  }
   }
   try{
     Update conList;
   }catch(DmlException de ){
      System.debug(de);
   }
}

If it help mark as solution to help other .

Thanks 
Manoj
SkeeterSkeeter
I tried the update that you provided, but it's not updating the contact with the case survey date.
ManojjenaManojjena
HI Lilranger,

Please set debug log add below code to your triggger and post the log ,as per my knowledge if the condition you have added in your trigger code is correct then it should work .
 
trigger ContactSupportSurveyDates on Case (before update) {
   List<Contact> conList=new List<Contact>();
   Map<Id,String> recTypeMap=new Map<Id,String>();
   for(RecordType rec :[Select ID, Name From RecordType Where sObjectType = 'Case']){
      recTypeMap.put(rec.Id,rec.Name);
   }
   for (Case cs : trigger.new){
      if(cs.Survey_Date__c != Trigger.oldMap.get(cs.Id).Survey_Date__c){
	    
	     if(recTypeMap.get(cs.RecordTypeId) =='Customer_Service' || recTypeMap.get(cs.RecordTypeId) =='CustomerSupport'){
		    if(cs.Survey_Date__c != null){
			    System.debug('*********ist***************'+cs.ContactId);
			   Contact con=new Contact(Id=cs.ContactId,Last_Support_Survey_Date__c = cs.Survey_Date__c);
			   conList.add(con);
		   }
		 }if(recTypeMap.get(cs.RecordTypeId) =='Pharmacy_Implementation'){
		   if(cs.Implementation_Survey_Date__c != null){
		       System.debug('**************2nd**********'+cs.ContactId);
			   Contact con=new Contact(Id=cs.ContactId,Last_Implementation_Survey_Date__c = cs.Implementation_Survey_Date__c);
			   conList.add(con);
		   }
		 }
	  }
   }
   try{
     System.debug('******conList*******'+conList);
     Update conList;
   }catch(DmlException de ){
      System.debug(de);
   }
}

Incase anny issue posting your code send your log to my email .(manojjena20@gmail.com)