You need to sign in to do that
Don't have an account?
Tillu
please correct this below trigger ?
I have 2 objects Policy , Interview. On interview record policy lookup is there. If interview fields Contact name matches with policy field contact name and Interview field Insured name matches with any policy record's Annuity name Then it should pull the policy on to the Interview record on policy look up field.
I have writtened below code. But it was not works properly. There is no immediate update for the Policy look up field. Can any one correct below code ?
trigger Interview_PolicyUpdate on Interviews__c
(before insert,before update) {
set<id> cset = new set<id>();
set<string> Aset = new set<string>();
for(Interviews__c Intr : Trigger.new){
If(Intr.Contact__c != Null){
cset.add(Intr.Contact__c);
}
}
List<policy__c> po = [select Id,name,Contact__c,Type__c,Annuitiant_Name__c from
Policy__c where Contact__c in:cset ];
try{
for(Interviews__c Inr : Trigger.new){
for(Policy__c p : po){
//If(Inr.Annuitant_Name__c !=null){
if(p.Contact__c == Inr.Contact__c && Inr.Insured_Name__c == p.Annuitiant_Name__c){
Inr.Policy1__c = p.Id;
}
}
}
}
catch(Exception e){
System.Debug(e.getMessage());
}
}
I have writtened below code. But it was not works properly. There is no immediate update for the Policy look up field. Can any one correct below code ?
trigger Interview_PolicyUpdate on Interviews__c
(before insert,before update) {
set<id> cset = new set<id>();
set<string> Aset = new set<string>();
for(Interviews__c Intr : Trigger.new){
If(Intr.Contact__c != Null){
cset.add(Intr.Contact__c);
}
}
List<policy__c> po = [select Id,name,Contact__c,Type__c,Annuitiant_Name__c from
Policy__c where Contact__c in:cset ];
try{
for(Interviews__c Inr : Trigger.new){
for(Policy__c p : po){
//If(Inr.Annuitant_Name__c !=null){
if(p.Contact__c == Inr.Contact__c && Inr.Insured_Name__c == p.Annuitiant_Name__c){
Inr.Policy1__c = p.Id;
}
}
}
}
catch(Exception e){
System.Debug(e.getMessage());
}
}
logontokartik
Please try below
Jen Bennett
Try to toss in a couple system debug messages to check your if statement, make sure you are entering it.