A business has the requirement that when a new opportunity is created Inactive companies and Inactive Persons should not able to be selected from within the fields of the web-picker.
This is a type of rule that will only need a simple statement, and these is no complex code needed to enforce the business rule.
In the image below you can see that I can select the company Gate Howe BUT this company has been marked as 'Inactive'.
If I go ahead and select the 'Active' company Gatecom, I would be shown the list of persons that includes 'David Costello' who I know is 'Inactive' as in the image below.
Both of the fields above (oppo_primarycompanyid and oppo_primarypersonid) are of the entry type 'Search Select Advanced'.
I can implement my business rule by using a properties of this field type called the 'Search SQL clause'. You can read more about using this property within the technical articles.
To hide the InActive companies I need to add the following SQL clause to the field definition screen for the 'oppo_primarycompanyid' field.
To make this change, navigate in the System Administration screens to
Administration -> Customization -> Opportunity
Click on the field oppo_primarycompanyid and change the properties
Adding this clause will only retrieve those companies where the comp_status is NOT set to 'Inactive'.
To hide the InActive person I need to add the following SQL clause to the field definition screen for the 'oppo_primarypersonid' field.
pers_status !='InActive' or pers_status is null
Adding this clause will only retrieve those persons where the pers_status is NOT set to 'Inactive'.
Note: This assumes that you have added the field 'pers_status' into the personboxlong screen so that it is status field is used in the application.
Once these changes have been made, you can see that the 'InActive' companies and persons are excluded: