You need to sign in to do that
Don't have an account?

How to compare fields of two different objects!!
Hi all,
I need help in trigger, There are two objects Intake_details and claim. The issue is,some claim records are being created that do not have a corresponding Intake Detail record
A claim record should only be created if its name(claim number) field matches the Intake_details name field.
Please suggest me how to do this.
I need help in trigger, There are two objects Intake_details and claim. The issue is,some claim records are being created that do not have a corresponding Intake Detail record
A claim record should only be created if its name(claim number) field matches the Intake_details name field.
Please suggest me how to do this.
Hope this helps!
Veenesh
All Answers
Hope this helps!
Veenesh
But in my case, IF claim name doesnt match with any of the intakedetail name then I need to a create a intakedetail record with the corresponding claim name.How will I achieve that?
trigger preventinsert on Student__c (before insert) {
//creating set strings to hold PAN of both objects
set<string> BCPAN = new set<string>();
set<string> SMPAN = new set<string>();
for(student__C FORSTUD: trigger.new){
SMPAN.add(FORSTUD.Pan_Card_Permanent__C);
}
for(blacklisted_candidate__C FORBC : [SELECT ID, PAN__c FROM blacklisted_candidate__C WHERE PAN__c IN :SMPAN]){
BCPAN.ADD(FORBC.Pan__C);}
for(student__C FORSTUD:trigger.new){
If (!BCPAN.CONTAINS(FORSTUD.Pan_Card_Permanent__C)){
FORSTUD.adderror('Blacklisted Candidate - PAN appears in blacklisted candidate Object');}}}