web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

[Phone call] - Custom filter on partylist field "to"

(0) ShareShare
ReportReport
Posted on by 200

Hi, 

I Want to apply a custom filter to the field "to" of phone call activity. The idea is to dispaly only the contacts related to a company. 

I used a javascript code in order to achieve this, but it looks like the filter doesn't apply. 

Here is my code : 

addLookupFilter = function(_context) {
			
	 var fetchXml = "";

	 _context.getControl("to").addCustomFilter(fetchXml, "contact");

}

formContext.getControl("to").addPreSearch(function () {

	addLookupFilter(formContext);

});

Thanks, 

Hicham

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi Hicham GRC,

    I tested with the following code and it could work:

    function onLoad(executionContext){
    	formContext = executionContext.getFormContext();
    	formContext.getControl("to").setEntityTypes(['contact']);
    	formContext.getControl("to").addPreSearch(addLookupFilter);
    }
    
    function addLookupFilter(){
    	var fetchXml = "";
    	formContext.getControl("to").addCustomFilter(fetchXml, "contact");
    }

    This is my account and it's contact:

    pastedimage1639465834819v1.png

    pastedimage1639465915891v2.png

    Result:

    pastedimage1639466068816v3.gif

  • Hicham GRC Profile Picture
    200 on at

    Hi Steve,

    Thanks for the help !

    I added the line ?formContext.getControl("to").setEntityTypes(['contact']); and turned off the automatic resolutions on the field and works fine ! Otherwise, it always dispaly recent records when you click on the field.

    pastedimage1639483932824v1.png

    KR, 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Pallavi Phade Profile Picture

Pallavi Phade 98

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 60 Super User 2025 Season 2

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans