function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mohd NabeelMohd Nabeel 

Create a field on Account called “Out_of_Zip”, checkbox, default off When a Billing Address is modified, get the new Postal Code. Then check which Contacts on the Account are outside that Postal Code. If 1 or more Contacts are outside of the P

i am new to salesforce and i am trying to achieve this task... i get the question that what it is saying, but not able to get it how will i achieve this... 
Ajay K DubediAjay K Dubedi
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_2


Make sure initially, the  Billing postal code for the account and mailing postal code for contacts are similar and not empty.
 
Trigger 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;

}
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Akash KainturaAkash Kaintura
It's not working do i need to make an extra Mailing Postal code field in contact ?