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:

Graphical user interface, application

Description automatically generated


Comments

Popular posts from this blog

The supplied reference link is invalid Error in Cloudflows

Retrieve Email Recipients (TO, CC, BCC) in Cloud Flow

Set Dynamic Recipients of D365 Email in Power Automate