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 :
Microsoft Dynamics CRM (Archived)

Java Script filter condition in dynamics 365

(0) ShareShare
ReportReport
Posted on by 445

Hello Experts,

i want to add an extra parameter for my filter condition but i dont know how to do it.

At the moment we select all accounts with the businesstypecode "3", but i want to select the codes "4" and "5" as well.

I just need a simple "or" but i work with JScript for the first time ^^

    Filter.filterMaschinenringAccounts = function () {
        var maschinenringFilter = "<filter type='and'><condition attribute='businesstypecode' operator='eq' value='3'/></filter>";
        Xrm.Page.getControl("mrd_lu_zugehoeriger_mr").addCustomFilter(maschinenringFilter, "account");
}

Thank you in advance.

Léon

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    You can change your filter type and add multiple conditions:

    var maschinenringFilter = "<filter type='or'>

    <condition attribute='businesstypecode' operator='eq' value='3'/>

    <condition attribute='businesstypecode' operator='eq' value='4'/>

    <condition attribute='businesstypecode' operator='eq' value='5'/>

    </filter>";

    This is basically the filter part of the fetchXml.

    If you need to get the different types of syntax, you can use Advanced Find to build your filter and download the FetchXml. Within the Xml, copy the Filter portion of the Xml to use it in the custom Filter.

    Hope this helps.

  • Verified answer
    chikhaleankush Profile Picture
    547 on at

    Please find below the XML you need

    <filter type='and'>
    	<filter type="or">
    	<condition attribute='businesstypecode' operator='eq' value='3'/>
    	<condition attribute='businesstypecode' operator='eq' value='4'/>
    	<condition attribute='businesstypecode' operator='eq' value='5'/>
    	</filter>
    </filter>


    Ps. Mark this as answered if it solves your issue.

  • Suggested answer
    Community Member Profile Picture
    on at

    Leon,

    I agree with Arvin.. Use advanced find and filter the the accounts based on the condition and download the fetch XML. Then cut the filter condition part and add it to the Javascript. 

  • BlackBeard Profile Picture
    445 on at

    Thank you for your help!

        var maschinenringFilter = 
         "<filter type='and'> "  +
            " <filter type='or'> " +
              " <condition attribute='businesstypecode' operator='eq' value='5'/>  " +
              " <condition attribute='businesstypecode' operator='eq' value='4'/> " +
              " <condition attribute='businesstypecode' operator='eq' value='3'/> " + 
             " </filter> " +
          "</filter>";


    With this code it works fine :)

    Regards
    Léon

  • ajyendra Profile Picture
    1,738 on at

    Hi,

    What If I have a lookup Field contain both account and Contact Records just like Customer Field in Case Form. I want to Show Records of only account with RelationShip type is Customer . Then What we prefer to filter that lookup field.

    Thanks

    Ajyendra

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans