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

Community site session details

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

Phone Party list custom filtering not working

(0) ShareShare
ReportReport
Posted on by 277

Hi Experts, i have been struggling to get a custom filter on phonecall to/from field to work. Here I'm trying to pull only the contacts which are originated from the Regarding Lead record. csjs is our custom common library. 

 

function leadToFromFilters(executionContext) {
    debugger;
    formContext = executionContext.getFormContext();
    var regardingObject = csjs.getLookup("regardingobjectid");
    var regardingId = regardingObject.id;
    var directionCode = csjs.getFieldValue("directioncode");
    var contactFilter = ""   ""   "";
    if (regardingObject !== null && regardingObject.entityType === "lead") {
        if (directionCode === true) { //Outgoing
            formContext.getControl("to").addCustomFilter(contactFilter, "contact");
        }
        if (directionCode === false) { //incoming
            formContext.getControl("from").addCustomFilter(contactFilter, "contact");
        }
    }
}

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Phone Party list custom filtering not working

    Hello,

    I don't know anything about csjs library so I will provide code using OOB JS:

    function leadToFromFilters(executionContext) {
        var formContext = executionContext.getFormContext();
        var regardingObject = formContext.getAttribute("regardingobjectid").getValue();
    	
    	if (regardingObject == null) {
    		return;
    	}
    	
        var regardingId = regardingObject[0].id;
        var directionCode = formContext.getAttribute("directioncode").getValue();
    	
        var contactFilter = "";
        if (regardingObject[0].entityType === "lead") {
            if (directionCode === true) { //Outgoing
                formContext.getControl("to").addCustomFilter(contactFilter, "contact");
            }
            if (directionCode === false) { //incoming
                formContext.getControl("from").addCustomFilter(contactFilter, "contact");
            }
        }
    }

    If code doesn't work well you can troubleshoot it using browser tools:

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 241

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 164 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 153

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans