You need to sign in to do that
Don't have an account?
Error: Compile Error: Unexpected token
Hi,
I am trying to write a trigger on a custom object called Job Application. It has 2 fields that are lookup type called Candidate and Position. I am trying to write a trigger that would not let the a candidate apply for a position more than once.
Though at this point I am not expecting the code to do what is required, I am quite baffled with the compile error. And am not able to shake it.
The code is given below, getting Error: Compile Error: Unexpected Token: ja.Candidate__c at line 8 column 14
trigger jaduplicate on Job_Application__c (before insert, before update) {
Map <String, Job_Application__C> jamap = new Map <String, Job_Application__c>();
for (Job_Application__c ja : system.trigger.new){
if(ja.Candidate__c != null && ja.Candidate__c != system.trigger.oldMap.get.(ja.id).Candidate__c){
jamap.put(ja.Candidate__c, ja);
jamap.put(ja.Position__c, ja);
} else {
for (ja.Candidate__c == system.trigger.oldMap.get.(ja.id).Candidate__c){
if (ja.Position__c == system.trigger.oldMap.get.(ja.id).Position__c){
ja.Position__c.adderror('Job Application already exists for the candidate');
} else {
jamap.put(ja.Candidate__c, ja);
jamap.put(ja.Position__c, ja);
}
}
}
}
}
Any help or suggestion as to why I am getting the error. And what that error means.
Thanks
KD
Couple of things:
trigger jaduplicate on Job_Application__c (before insert, before update) { Map <String, Job_Application__C> jamap = new Map <String, Job_Application__c>(); for (Job_Application__c ja : trigger.new){ if(ja.Candidate__c != null && ja.Candidate__c != trigger.oldMap.get(ja.id).Candidate__c){ jamap.put(ja.Candidate__c, ja); jamap.put(ja.Position__c, ja); } else { while (ja.Candidate__c == trigger.oldMap.get(ja.id).Candidate__c){ if (ja.Position__c == trigger.oldMap.get(ja.id).Position__c){ ja.Position__c.adderror('Job Application already exists for the candidate'); } else { jamap.put(ja.Candidate__c, ja); jamap.put(ja.Position__c, ja); } } } } }
thanks for the suggestion
could you please point out what is the difference between
system.trigger.new and trigger.new
get.(ja.id) and get(ja.id)
when executing if we get an error for system.nullpointerexecution what does than mean?