Change 'Lookup For' in Party list Using JavaScript

 Introduction: Party list like "TO" usually contain record of type Accounts, Contacts, Knowledge Articles, Leads, Users

Graphical user interface, text, application, email

Description automatically generated

 

If you want to restrict the Lookup values, write the below script on load on the form and also on change of the partly list

 

var lookup = {

    dropdown: function (execContext) {

        var formContext = execContext.getFormContext();

        if (formContext.getAttribute("dropdown").getValue() != null) {

            dropdown = formContext.getAttribute("dropdown").getValue();

            var LookUpFor = ['account'];

            var fieldlist = ['to','cc','bcc'];

 fieldlist.forEach(

        function (item, index) {

            formContext.getAttribute(item).setValue(null);

            formContext.getControl(item).setEntityTypes(LookUpFor);

        });

        }

    }}

 

Here for each value in fieldlist, the lookup for will be set to account.


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