Adding a contractor page field to a deal filter

Consider adding a contractor page field to a deal filter using the Business Size property of the contractor.

This property is of the Drop down list type with 4 items.

In the Deal object, open the Filter tab and add the Business Size property. Type: Drop down list. Items: SOHO, Medium business, Large business, Enterprise).

 

After that, save and publish the object.

Open the Scripts tab of the Deal object.

If there are no scripts, create a new scripts module

Add this code:

protected override void OnSetupFilter(ICriteria criteria, IEntityFilter filter)
{
    var saleFilter = filter as ISaleConfigExtFilter;
    if (saleFilter != null)
    {
        if (saleFilter.BusinessSize != null)
        {
            var contractorAlias = "cc";
            criteria.GetOrCreateAlias("Contractor", JoinType.InnerJoin, ref contractorAlias);
            criteria.Add(Restrictions.Eq(contractorAlias + ".BusinessSize", saleFilter.BusinessSize));
        }
    }
}
 

After that, publish the script and restart the server.

In the web interface, go to the Deals section and click Edit Filter.

 

On the Filter Fields tab, find the Business Size item in the Available Elements unit.

 

Double click on the Business Size item to move it to the Selected unit. 

The result is shown below.