You need to sign in to do that
Don't have an account?
MyGodItsCold
How Do I: Limit # Contacts with Checkbox Checked to 2
I'm looking for advice on how to best implement the following:
A contact has a check box - a custom field. When the user checks the box, I want to run a query to see if there are 2 Contacts associated with the Account who have that box checked - if so, deny the ability to check the box & notify the user that s/he already has 2 Contacts checked.
I'm thinking a trigger, but in the ultimate implemenation, I'd like to tell the user:
Hey, here are the 2 contacts you've already got checked - demote one to promote the current one, or bail out.
So, this would seem to suggest an S-Control - but if I want to put it on the Contacts Pagelayouts, would that get into an override situation? And is that a matter of somehow cloning what's there, but just overloading the Save button?
A contact has a check box - a custom field. When the user checks the box, I want to run a query to see if there are 2 Contacts associated with the Account who have that box checked - if so, deny the ability to check the box & notify the user that s/he already has 2 Contacts checked.
I'm thinking a trigger, but in the ultimate implemenation, I'd like to tell the user:
Hey, here are the 2 contacts you've already got checked - demote one to promote the current one, or bail out.
So, this would seem to suggest an S-Control - but if I want to put it on the Contacts Pagelayouts, would that get into an override situation? And is that a matter of somehow cloning what's there, but just overloading the Save button?
chris
Message Edited by cmark on 12-05-2007 08:02 PM
Chris, Thanks for responding. Yesterday, I opened for testing a trigger which checks to see if there are two others with the check box checked, and if so, it aborts with a message. I can't wait for Visualforce to go to production! We did enough testing on it to confirm it was what we're hoping - but without firm time lines, we have disengaged.
Thanks
chris
Sorry. Yes, I wrote an APEX trigger on Contacts. It's a Before Update trigger. I test the .old vs the .new values of the checkbox to see if it's just been checked (false to true), or unchecked (true to false). If checked, I query to see how many are currently checked.
We're in a pretty structured environment. We use multiple sandboxes, and when something is developed, we eventually move it into the sandbox with all the data (instead of strategically designed data points geared to hit one of each kind). That event I refer to as 'open for testing'. I've already tried to get it to fail & have come up short, so now it's time for our super-user / admin / owner team to test it.
In addition to structured migration from development to test to production, we engage version control - but allow for fast prototyping. We're getting better & better at this each day.