function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MMA_FORCEMMA_FORCE 

Help with Trigger....

Hi all:

   I have the following trigger which I need to update everytime a new or old update occurs:

I keep getting this error:

Compile Error: Incompatible key type String for MAP:smileyvery-happy:ecimal,Id at line 18 column 82

 

Now yes, Term is a decimal/formula field.... 

Also within my trigger I need to update a field that is a string but will update from the Term field...

Could someone shine some light on my error?? Please

 

trigger UpdateSARQ on Course (before insert, before update) {
List<Course> htoUpdte = new List<Course__c>();
Map<String, Id> rTypes = new Map<String, Id>();
Map<Decimal, Id> rTypes2 = new Map<Decimal, Id>();

for(Subject__c rType :[SELECT Id,Subject_Area__r.Name,Term__c FROM Subject__c]) {
rTypes.put(rType.Subject_Area__r.Name, rType.Id);
rTypes2.put(rType.Term__c, rType.Id);
}


Id oppRecType1 = rTypes.get('Subject_Area__r.Name');


for(Course__c ch: trigger.new)
{

if(rTypes.get('Subject_Area__r.Name')== ch.Subject__c && rTypes2.get('Term__c')== ch.Term__c){
ch.SARQ__c=rTypes.get('Id');
}

htoUpdte.add(ch);

}
}

SPDSPD
In second condition you are comparing Term__c with ID...and hence the error.