2 réponses
Hi Mohd Nabeel,I have understood your requirements and made a solution for it.I have made a trigger. But to achieve this you should have an Account with more than 2 contacts and also a custom checkbox field in Account object.If you don't know how to make custom fields then prefer this link-https://help.salesforce.com/articleView?id=adding_fields.htm&type=5 (https://help.salesforce.com/articleView?id=adding_fields.htm&type=5)https://trailhead.salesforce.com/en/content/learn/projects/suggestion_box/suggestion_box_2Make sure initially, the Billing postal code for the account and mailing postal code for contacts are similar and not empty.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.Thanks and Regards,Ajay Dubediwww.ajaydubedi.comTrigger Test_Out_of_Zip on account (after update) {
public static boolean flag=true;
If(flag==true) {
account acc = [select id,Out_of_Zip,BillingPostalCode from account where id in : trigger.new];
List<contact> conList = [select id, name,MailingPostalCode from contact where accoundId in : acc];
List<contact> conListNew = new List<contact>();
for (contact con : conList)
{
if(acc.BillingPostalCode != con.MailingPostalCode)
{
conListNew.add(con);
}
}
If(conListNew.size()>=1)
{
acc.Out_of_Zip = true;
}
flag=false;
update acc;
}
}