Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Filtering a query with .addCustomFilter using only one entity in a party list

Posted on by

I'm using a filter to only take systemuser and queue for the lookup in the from field for an email. We have found that there are a LOT of queues available because of the system generated queues (starting with a <). So what I want to do, is not display any queues in the lookup that are inactive. This way the CRM users can just set queues as inactive if they do not want to see them, and I can create a filter so that it finds any active system generated queues.

The issue here is that because it is part of a party list, the javascript function fails. So I am using:

filter =
  "<filter type='and'>" +
  "<condition attribute='statecode' operator='eq' value='0' />" +
  "</filter>";
Xrm.Page.getControl(fieldName).addCustomFilter(filter);


However, this brings up an error, as there is no "statecode" for a systemuser.

Is there any way that I can create part of the filter that will only check against certain entities? would be great if I could do 

attribute='queue.statecode'

however this checks each entity in the party list against queue.statecode which of course doesn't exist for other entities.

*This post is locked for comments

  • Suggested answer
    MicWit Profile Picture
    MicWit on at
    RE: Filtering a query with .addCustomFilter using only one entity in a party list

    Problem solved, all I needed to do was change the line to Xrm.Page.getControl(fieldName).addCustomFilter(filter, "queue");

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans