0

i have two objects obj1,obj2. obj1 is parent for obj2,these 2 objects having three check box fields ch1,ch2,ch3. when am trying to make an update on Obj1 with the a condition i.e if any field ch1,ch2,ch3 are changed from True to False then only update obj2.Do not update when ch1,ch2,ch3 is changed from False to True. How to achieve this scenario.

Thanks in advance..

0

I just added an example here you can check like this.

For(Object1 obj : Trigger.newMap){
    Object1 objOld = Trigger.oldMap.get(obj.Id);
    if((obj.ch1 != objOld.ch1 && !obj.ch1) || (obj.ch2 != objOld.ch2 && !obj.ch2) || (obj.ch3 != objOld.ch3 && !obj.ch3)) {
        //perform your logic here
    }
}
2
  • Thanks for your suggestions .I tried this for getting records but here the problem is with updating child records fields,let me explain briefly in obj1 ch1 is updated then Obj2 ch1 only reqire update do not perform on other field(ch2,ch3). here is my sample code List<obj2> Childrecords=new List<obj2>(); for(obj1 o1:updatedobj1list){ for(obj2 o2:chilldsOfObj1){ o2.Ch1=o1.Ch1; o2.Ch2=o1.Ch2; o2.Ch1=o1.Ch3; Childrecords.add(o2); } } UPdate Childrecords; – baskar G Feb 28 '16 at 13:57
  • can you please paste your code here for better clarity? – SFDC Learner Feb 29 '16 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.