A few days ago, while running a training program for a partner company, we came up with a requirement for dynamically setting SharePoint field values in the “New” and “Edit item” SharePoint forms. Every SharePoint developer comes across this sooner or later, because customers often want a form’s behavior extended beyond the standard SharePoint functionality.
Let’s imagine the following scenario: we’ve come back from a SharePoint conference, and we have a list of leads that need to be categorized and consolidated. We create a very simple SharePoint list that might be, but does not have to be, part of a skybow case file. The list contains the following fields:
As you can see, for each lead, standard CRM values like Phone Number, Company, Position in company, Industry (lookup to the “Industries” SharePoint list), Subindustry (with its own lookup field to the “Industries” list), and Lead category (A – premium lead to C – loose lead) have to be set.
The standard SharePoint “Add” or “Edit” form would look like this:
Our requirements are as follows:
1. It should to be possible to add a new industry and subindustry directly from the leads form without navigating to those respective lists, and therefore losing the context.
2. If the field “Company” is filled in, the fields “Position” and “Industry” have to be enabled (by default, they should be disabled).
3. If “Industry” is selected, the field “Subindustry” has to be visible and marked as a required field; otherwise the field should not be visible (and therefore also not required).
4. Subindustry always has to be limited to the selected Industry.
5. If industry is set to “Information Technology,” the choices in the field “Category” have to be limited to “A – Premium lead” – or leads from that selected industry are premium leads.
6. If the field “Position” contains the phrase “CEO,” automatically set the “Category” field to “A – Premium lead”
As you can see, those are some standard requirements that can be expected in pretty much every SharePoint business solution. So, let’s start. Our goal is to get this running in less than 15 minutes.