Add a Custom Attribute to the Partner Finder Filter
In this example, let's look at how to add a custom Region filter to your Partner Finder application. This will let users filter partner search results by region.
In VBCS, complete these steps:
-
Navigate to Web Applications > partnerfinder > Flows > partner-finder.
-
Click the Variables and Types icon (x) > Variables tab > aggregations.
-
In the Default Value region, add the custom Region field to the aggregations using the below code:
"Region": { "ignore": true, "terms": { "attribute": "Region_c", "minBucketCount": 1, "maxNumberOfBuckets": 4, "other": false, "missing": false, "localize": true } },
-
Navigate to Web Applications > partnerfinder > Flows > partner-finder-search.
-
Click the Variables and Types icon (x) > Variables tab > additionalCriteria.
-
In the Default Value region, add the custom attribute to additionalCriteria using the below code:
"ElasticCustAggregation": { "attribute": "Region_c", "op": "$in", "values": [] },
-
Add the custom field name, Region, to the string repository so that it can be referenced within the application.
-
Navigate to Web Applications > partnerfinder > Flows > partner-finder > partner-finder-search > Designer > click the Code button.
-
Add the custom attribute to the partner finder search html page using the below code:
<oj-bind-if test="[[ $variables.buckets.Region && $variables.buckets.Region.length>0 ]]"> <div> <oj-label id="odps-pf-search-filter-region-Label" class="odps-pf-search-results-filter-label"><oj-bind-text value="[[ $application.translations.app.searchresults_filter_region ]]"></oj-bind-text></oj-label> <oj-checkboxset id="odps-pf-search-filter-region-checkbox" labelled-by="odps-pf-search-filter-region-Label" class="odps-pf-search-results-filter-checkbox" value="{{ $variables.additionalCriteria.Region.values }}"> <oj-bind-for-each data="[[ $page.variables.buckets.Region ]]"> <template> <oj-option value="[[$current.data.key]]"> <oj-bind-text value="[[ $current.data.localizedKey + ' (' + $current.data.count + ')' ]]"></oj-bind-text> </oj-option> </template> </oj-bind-for-each> </oj-checkboxset> </div> </oj-bind-if>
-
Navigate to Web Applications > partnerfinder > Flows > partner-finder > partner-finder-search > Actions > SearchKeywordValueChangedAction.
-
Update the condition for ifFilterIsEmpty as follows:
[[ $page.variables.additionalCriteria.Country.values.length === 0 && $page.variables.additionalCriteria.Tier.values.length === 0 && $page.variables.additionalCriteria.Type.values.length === 0 && $page.variables.additionalCriteria. Region.values.length === 0]]
-
Navigate to Web Applications > partnerfinder > Flows > partner-finder > partner-finder-search > Actions > refreshFilters.
-
Add an additional refresh condition for the custom attribute as mentioned below:
-
Add an if condition to "Run in Parallel" as follows:
[[ $page.variables.buckets.Region && $page.variables.buckets.Region.length > 0 ]]
-
Add the call component method and link it to the corresponding check box component (odps-pf-search-filter-region-checkbox):
-
-
Click the Play icon to run the application to verify the change.
-
Verify the change. Notice that there is now a custom Region filter in your Partner Finder application.