Design a site like this with WordPress.com
Get started

Filter Lookup Based on Option Set value

Today, I met with a requirement where we need to achieve filtering of lookup values based on option set value selection.

The requirement was to filter Loan Category(lookup field), based on Loan Type(optionset field).
There were three different types of Loan Types in the system (optionset field).

  • Home Loan
  • Business Loan
  • Personal Loan

I had to provide the required filter on “Lead” entity. So, below are the steps which I followed.

  • Created a Global OptionSet, having Loan Types.
  • Created a field Lead Loan Type(blog_leadloantype) of option set type on Lead entity and called the Global Option Set
  • Created a field Lead Category(blog_leadcategory) of lookup type on Lead entity. Which have a relationship with one of our custom entity name Bank Code.
  • Created a field Loan Type(blog_loantypes) of option set type under Bank Code entity. (required for filtering values)

Below is the screenshot of Bank Code entity, from advanced find which show the data to be filtered in the below desired format.

Advance Find on Bank Code entity

Create a new webresource of Javascript type and paste the below the code in the editor:

(function () { }(window.BankNotes = window.BankNotes || {}));
(function (BankNotesFilter) {
BankNotesFilter.onCategoryChange = function (executionContext) {
var formContext = executionContext.getFormContext();                                  
 
//Check if the field is not null
if (formContext.getAttribute("blog_leadloantype").getValue() != null) {

//Apply Search on lookup field OnClick 
formContext.getControl("blog_leadcategory").addPreSearch(function(){
var loancode = formContext.getAttribute("blog_leadloantype").getValue();        

//Apply the filter condition
var filter = "<filter type='and'><condition attribute='blog_loantypes' operator='eq' value='" + loancode + "' /></filter>";

//Populate the filter values into lookup field
formContext.getControl("blog_leadcategory").addCustomFilter(filter);
});
}
};
}(window.BankNotes.BankNotesFilter = window.BankNotes.BankNotesFilter || {}));

The above script will triggered on the onChange event for Lead Loan Type(blog_leadloantype). Function which needs to be called – BankNotes.BankNotesFilter.onCategoryChange

I hope this helps you. 👍

Advertisement

Omnichannel for Customer Service – Part 4

Let’s learn how to test authenticating our portal user via Omnichannel chat.

Follow the below steps for providing our Contact access to the portal.

Initiating the chat from the portal. Sign-in as Contact(Avinash Verma).
Also, check that the agent status on the omnichannel agent screen is available. If the agent does not have the capacity then the call won’t come to the agent screen.

Below we can see that the contact name appears on the chat notification which appears on the agent screen. Rather than Visitor 1 which would appear for an anonymous user.

Hope this helps!!!