Tech Support > Microsoft Windows > Windows CRM > Picklist Validation / Constraint
Picklist Validation / Constraint
Posted by CHIRAG SHAH on June 22nd, 2007


I want to have picklist validation constraint:
For example: There are 3 Picklist: Country, State, City
Upon selection of Country, dynamic values should be load into States
and upon selection of States, dynamic values should be load into City.
i.e: Upon Country ->Canada selection gives values ON, BC, AB, etc into
States Picklist and States->ON selection gives values Toronto,
Windsor, Sudbary etc into City Picklist.
How it can be done? Can you please provide the code and steps as well?

Posted by RonDumosch@gmail.com on June 24th, 2007


I believe what you are looking to do can be located on page 482 in
Mike Snyder's book, Working with Microsoft Dynamics CRM 3. If you
have not picked this book up, I highly recommended it for doing these
types of development tasks. In lieu of that, here is the basic
pattern to use. If user selects US for instance, you would use the
AddOption() method on the states field to add the 50 states. If the
user then selects Canada as the country, you would use the
DeleteOption method to delete the 50 states, an dthen use the
AddOption() to now add the Canadian values. All you need to do is
check if the values already exist, and that will tell you what you
need to delete. IE: loop through the length of the picklist and
delete all of the values and then add the correct values. That should
do it for you. Dont forget you will need a reset snippet that if the
user changes a value out of sequence to reset the fields to a
default. So if someone chooses U.S., then Texas, then changes to
Canada, make sure you reset the values of subsequent picklists like
state and city. Good Luck

Ron