You need to sign in to do that
Don't have an account?
Bob
Save error: illegal assignment from Ext_Warranty__c to Unit__c
Hello, i'm sucking up my pride a little bit, but the code below appears to correct but I get a Save error: illegal assignment from Ext_Warranty__c to Unit__c when I try to compile it. If anyone could help with this I would appreciate it as I am going out my mind trying to figure out why this code is failing.
trigger UpdateUnitExtWarranty on Unit__c (before insert, before update) { // Step 1: Create a set of all emails of Users to query Set<String> allpc = new Set<String>(); for (Unit__c newUnit :Trigger.new) { if (newUnit.Product_Code__c != null) { allpc.add(newUnit.Product_Code__c); } } // Step 2: Query for all the extended warranties in Step 1 List<Extended_Warranty__c> potentialextwrnty = [SELECT Id, Product_Code__c FROM Extended_Warranty__c WHERE Product_Code__c IN :allpc]; // Map<String, Extended_Warranty__c> extwrntyMap = new Map<String, Extended_Warranty__c>(); for (Extended_Warranty__c e : potentialextwrnty) { extwrntyMap.put(e.Product_Code__c, e); } for (Unit__c newUnit : Trigger.new) { if (newUnit.Product_Code__c == null) { Unit__c extendedwarranty = extwrntyMap.get(newUnit.Product_Code__c ); if (extendedwarranty != null) { //rename extended_warranty fieldbelow on unit page newUnit.Ext_Warranty__c = extendedwarranty.Id; } } } }
Extended_Warranty__c extendedwarranty = extwrntyMap.get(newUnit.Product_Code__c );
All Answers
Extended_Warranty__c extendedwarranty = extwrntyMap.get(newUnit.Product_Code__c );