You need to sign in to do that
Don't have an account?
Nandhini S 3
need help on a before update trigger
Hi guys,
I need to create a trigger to throw error for the below scenarion...can someone help me with this.
Object1 is parent and Object2 is child. There is a picklist field 'Role' in Object2 with values ('A','B','C'). Object1 can have only one Object2 record with the same role.
If an Object1 has two Object2 child records.First record with Role = 'A' and second record with Role = 'B'. If the second record is updated to Role = 'A' then an error should be thrown.
How can i write a before update trigger to throw error.
I need to create a trigger to throw error for the below scenarion...can someone help me with this.
Object1 is parent and Object2 is child. There is a picklist field 'Role' in Object2 with values ('A','B','C'). Object1 can have only one Object2 record with the same role.
If an Object1 has two Object2 child records.First record with Role = 'A' and second record with Role = 'B'. If the second record is updated to Role = 'A' then an error should be thrown.
How can i write a before update trigger to throw error.
Try Below Trigger Please Mark It As Best Answer If It Helps
Thank You!
Thanks for replying. For my scenario, error should be thrown, if there is already a related contact record with Role ='A' and the other related contact record Role is updated to 'A'. There should be only one related records with 'A' role.
Thanks
Thats The Code Doing
If Account Already Have Three Contact With Role A & B & C Now If We Insert/update Contact With Same Account With Role Either A & B & C gives error
the Account maynot have three contacts with Role A,B,C. It can have jus two contacts with A and B role, When the contact with B role is updated to A role, then the error should be thrown