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

How to make one contact as primary ?
Account has multiple contacts associated with it. I want to check one contact as primary and if new contact is added to account then that contact will be checked as primary.
How to achieve this ?
How to achieve this ?
To achieve this, you need to create one custom checkbox field in contact as a "primary" so when you click that check box that contact must be the primary contact others not.And then you can write a trigger to check if primary contact is true then throw error else allow to add a contact.
I also suggest you refer below link for more information.
http://salesforce.stackexchange.com/questions/93001/only-one-primary-contact-for-an-account
Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
Thanks and Regards
Sandhya
All Answers
To achieve this, you need to create one custom checkbox field in contact as a "primary" so when you click that check box that contact must be the primary contact others not.And then you can write a trigger to check if primary contact is true then throw error else allow to add a contact.
I also suggest you refer below link for more information.
http://salesforce.stackexchange.com/questions/93001/only-one-primary-contact-for-an-account
Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.
Thanks and Regards
Sandhya
Your code is working with little modification.
Modified code :
Thanks & Regards,
THUNDER CLOUD