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
Suchita UkeySuchita Ukey 

I have 2 objects Object 1-Contact Object 2- Property which has picklist field calles Status. I want to write a trigger when Status=Working contact object field should updte the Property object field.

Lukesh KarmoreLukesh Karmore
Hi  Suchita Ukey,
Please try below trigger or take reference, If it helps you then mark the best answer so it helps others.
trigger UpdatePropertyStatus on Contact(After insert){
set<id> conId=new set<id>();
 for(contact c:trigger.new){
if(c.Status!=trigger.oldmap.get(c.Id).Status &&   c.Status=='Working'){
conId.add(c.Id);
    }
 }
//property is child
list<Property> pr= [select id ,status,contact.status from property where contactId in : conId];
if(pr.Size()>0){
list<property> pList=new list<property>();
 for(Property p:pr){
if(p.contact.status=='Working'){
p.Status='Working';
pList.add(p);
      }
}
Update pList;
     }
}
Thanks,
Lukesh