You need to sign in to do that
Don't have an account?
umair khan 15
I want to update record of other object where there is a duplicate feild matching.. posting full details in comment
Create a new Custom objects Application and BlackList | ||||||||
Object Name Field Names
| ||||||||
Application Name,Pancard ,Phone | ||||||||
BlacKList Name,Pancard,phone | ||||||||
a. When ever we are inserting new Application it has to check pancard no of the new application record is | ||||||||
in the Blakc list or not . | ||||||||
b.If the pancard of the Appliction is in the blacklist object then update the blackList phone with new application phone no and throw error // This is the Code I have tried. It is throwing error where there is duplicate but not Updating the Blacklist phone number. |
List<applicant__c> app=trigger.new;
list<blacklist__c> blk=[Select name, Name__c,Pancard__c,Phone__c from Blacklist__c];
list<blacklist__c> b2=new list<blackList__c>();
for(applicant__c a:app){
for(blacklist__c b:blk){
if(b.pancard__c==a.PANCARD__c && b.Phone__c!=a.Phone__c){
a.adderror('Applicant Is Blacklisted');
b.phone__c=a.Phone__c;
b2.add(b);
}
}
}
update b2;
}