You need to sign in to do that
Don't have an account?

There are multiple Contact Records and one is primary among them. User is trying to un-select Primary
Hi All,
I am working on one scenario where there are Multiple Child Records for eg:Account is a parent and Under Account multiple child Objects Records will be there.In that child Object i have created one checkbox field called Primary and first record should be primary and if users adding another record as primary it has to thrwo error Message there is already one primary Record please unselect the existing record and add new record as primary marked
Eg:Let say under account 3 child records are there and 1 is primary already and user is trying to add the 3 rd record as primary it should throw error Message
NEXT There are 3 Multiple Child Records and one is primary among them and user is trying to delete the primary record without marking any other records as primary then it should throw error Message as User is trying to Delete primary Record without making another primary
If there is only one primary and user is trying to delete then it should allow the user to delete.
Note :Child Record Refers to Contact
Any one please guide me to help to implement this scenarios.
I am working on one scenario where there are Multiple Child Records for eg:Account is a parent and Under Account multiple child Objects Records will be there.In that child Object i have created one checkbox field called Primary and first record should be primary and if users adding another record as primary it has to thrwo error Message there is already one primary Record please unselect the existing record and add new record as primary marked
Eg:Let say under account 3 child records are there and 1 is primary already and user is trying to add the 3 rd record as primary it should throw error Message
NEXT There are 3 Multiple Child Records and one is primary among them and user is trying to delete the primary record without marking any other records as primary then it should throw error Message as User is trying to Delete primary Record without making another primary
If there is only one primary and user is trying to delete then it should allow the user to delete.
Note :Child Record Refers to Contact
Any one please guide me to help to implement this scenarios.
You can refer the below blog that explains how to achieve this.
https://force-base.com/2016/09/24/build-a-validation-by-shaking-hands-with-workflow-rules/
Hope that helps !
If it works kindly mark as an answer so that we can close this thread.
I would set checked as default value for Primary field, so any time a new Contact is created, it would be Primary by default. Then below trigger will modify previous records to false if the latest is true.
Can please explain how to use this code in before update/ after update trigger
Thanks
and then add the logic on its own piece of code
Regarding before, I would not advice to add logic or validations on "before" because un after can change anything you checked before and make it fails.