• Muneendar POC 6
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
Hi Guys, I've created 2 custom object with master detail relationship and I want a trigger which update child object when phone number in parent record gets changed, here is my code

trigger UpdateChildPhone on Parent_Dept__c (after insert) {
    Map<id, Parent_Dept__c> MapParent = new map<id, Parent_Dept__c>();
    //checking whether the value already exist or not.
    for(Parent_Dept__c ParentObj : Trigger.New)
    {
        If(Trigger.oldmap.get(ParentObj.id).Dept_Phone__c!= ParentObj.Dept_Phone__c)
        {
            MapParent.put(ParentObj.id, ParentObj);
        }
    }
    //fetching up the data from child with parent ID
    List<Child_Emp__c> ChildObjLst = new list<Child_Emp__c>();
    for(Child_Emp__c child : [SELECT Dept_Phone__c,Id,Parent_Dept__c FROM Child_Emp__c WHERE ID IN : MapParent.keyset()])
    {
      child.Dept_Phone__c= MapParent.get(Parent_Dept__c.id).Dept_Phone__c;
      ChildObjLst.add(child);
    }
        update ChildObjLst;                                           
    }

There is an error on bold colord code, can you please suggest your valuable suggestion please?
how to write trigger ,it should'nt allow more than 2 contacts for a single account
Hi 

Could you please check the below points and provide your answers

how to Create a  new Account and create a three tasks for it.
how to Create a new Account and attach three attachments for it
how to Write a SOQL to fetch all Accounts including records in Recyclebin.

Thanks