Filter Regarding using JavaScript
Introduction:
In this blog we will learn how to filter regarding based on another option set field. Also, we shall understand how we can set the default view for regarding.
Solution:
The below script will run on field change of “Type”, this is the option set based on which the regarding will be filtered.
Regarding: function (execContext) { var formContext = execContext.getFormContext(); if (formContext.getAttribute("type").getValue() != null) { Type = formContext.getAttribute("type").getValue(); switch (Type) { case 1: formContext.getControl("regardingobjectid").setEntityTypes(["contact"]); formContext.getControl("regardingobjectid").setDefaultView("{00000ABC-0000-0000-00BG-000010000147}"); break; case 2: formContext.getControl("regardingobjectid").setEntityTypes(["quote"]); formContext.getControl("regardingobjectid").setDefaultView("{00000ABC-0000-0000-00BG-000010000147}"); break; } } }
Here, the Entity Type- will be entity you want to show in regarding and default view will be the view whose id is set in this script.
Output: