locked
Adding custom filter make Show Only My Records not functioning RRS feed

  • Question

  • MS-CRM 2013, SP1/UR1 on premisses:

    I add a custom filter in JS to a standard lookup, e.g. parent account on account form using addCustomFilter. However, the Show Only My Records checkbox on the Lookup More Cords form has no effect, i.e. that filter is not applied. This also happened before UR1.


    Per

    Friday, September 26, 2014 6:17 PM

All replies

  • Saturday, September 27, 2014 7:46 AM
    Moderator
  • Hi,are you using that with presearch?:

    http://mscrmshop.blogspot.co.nz/2013/10/addcustomfilter-method-for-lookup.html

    http://msdn.microsoft.com/en-us/library/gg334266.aspx#BKMK_addPreSearch

     


    I Hope I could help. If I have answered please mark as 'Answer'. If was just helpful, please vote. Thanks and happy coding! Bruno Lucas, http://dynamicday.wordpress.com/

    Monday, September 29, 2014 2:05 AM
  •     SetParentLookup: function (lookupfield) {
            // Possible parent account types depends on current accounts type
    
            function ParentFilter(lookupctrl, viewid) {
                var accounttype = Xrm.Page.getAttribute("customertypecode").getValue();
                lookupctrl.setDefaultView(viewid);
                var fetchXml = '';
                fetchXml +=
                '<filter type="and">' +
                '<condition attribute="statuscode" operator="eq" value="1" />';
    
                switch (accounttype) {
                    case XXX.Account.AccountType.ACCOUNTGROUP:
                        fetchXml +=
                        '<condition attribute="customertypecode" operator="in">' +
                        '<value>' + XXX.Account.AccountType.ACCOUNTGROUP + '</value>' +
                        '<value>' + XXX.Account.AccountType.GLOBALACCOUNT + '</value>' +
                        '</condition>';
                        break;
                    case XXX.Account.AccountType.GLOBALACCOUNT:
                        fetchXml +=
                        '<condition attribute="customertypecode" operator="in">' +
                        '<value>' + XXX.Account.AccountType.GLOBALACCOUNT + '</value>' +
                        '</condition>';
                        break;
                    case XXX.Account.AccountType.SUSPECT:
                    case XXX.Account.AccountType.PROSPECT:
                    case XXX.Account.AccountType.CUSTOMER:
                        fetchXml +=
                        '<condition attribute="customertypecode" operator="in">' +
                        '<value>' + XXX.Account.AccountType.SUSPECT + '</value>' +
                        '<value>' + XXX.Account.AccountType.PROSPECT + '</value>' +
                        '<value>' + XXX.Account.AccountType.CUSTOMER + '</value>' +
                        '<value>' + XXX.Account.AccountType.ACCOUNTGROUP + '</value>' +
                        '<value>' + XXX.Account.AccountType.GLOBALACCOUNT + '</value>' +
                        '</condition>';
                        break;
    
                    case XXX.Account.AccountType.XXXEMPLOYEE:
                        break;
    
                    case XXX.Account.AccountType.LOCATION:
                        fetchXml +=
                        '<condition attribute="customertypecode" operator="in">' +
                        '<value>' + XXX.Account.AccountType.SUSPECT + '</value>' +
                        '<value>' + XXX.Account.AccountType.PROSPECT + '</value>' +
                        '<value>' + XXX.Account.AccountType.CUSTOMER + '</value>' +
                        '</condition>';
                        break;
    
                    default:
                }
    
                fetchXml += '</filter>'
                lookupctrl.addCustomFilter(fetchXml);
            }
    
            var lookupctrl = Xrm.Page.getControl(lookupfield);
    
            if (typeof (XXX.Account.ParentLookup) === "undefined") {
                XXX.Account.ParentLookup = lookupctrl.getDefaultView();
                lookupctrl.addPreSearch(function () { ParentFilter(lookupctrl, XXX.Account.ParentLookup); })
            }
        },


    Per

    Monday, September 29, 2014 1:24 PM