Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

addCustomFilter - How to filter with operator 'in' where value is an array of objects

(0) ShareShare
ReportReport
Posted on by

Hi, I'm trying to create a filter for addCustomFilter function where the value is an array of Guids (teamId), and the operator is 'in', but I can't seem to get the xml right.

I'm trying to iterate through the array and add a <value> tag for each guid in the array.

       var userTeams = dataService.GetTeamsIdOfUser(userId[0].id);
        
            var filter = "<filter type='and'><condition attribute='teamid' 
             operator='in'>";
            userTeams.forEach(function (val) {
                filter+= "<value='{" + val + "}'></value>"
            });
            filter += "</filter>";
            Xrm.Page.getControl("mtx_assign2userteam").addCustomFilter(filter,"team");


can anyone show me what I'm doing wrong?

Thanks in advance!

*This post is locked for comments

  • Suggested answer
    Daniel Wikell Profile Picture
    2,360 on at
    RE: addCustomFilter - How to filter with operator 'in' where value is an array of objects

    It looks like you are missing the end tag for the condition-tag. Try adding the </condition> right before you close the filter tag

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    RE: addCustomFilter - How to filter with operator 'in' where value is an array of objects

    Hi,

    You can add the filter condition as follows:                                                                                                                                                "<condition attribute='teamid' operator='in'>"+

    "<value>"+id1+"</value>"+

    "<value>"+id2+"</value>"+

    "</condition>"+

    "</filter>"+

    If found useful, please mark this answer as verified.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans