i could not applied filter help please!

Feb 28, 2013 at 2:45 PM
i used to silverlight crm lookup contol on my silverlight project.

i can use defult but i want to filter lookup

the code is below
   LookupFilterCustom lookupFilterCustom = new LookupFilterCustom();
   MylookupControl.FilteredView = lookupFilterCustom.run();

  public LookupView run(Guid ilceid)
    {
        LookupView lookupView = new LookupView();
        lookupView.DisplayName = "Mahalle Tanımları Ekranı";
        lookupView.ViewId = Guid.NewGuid();//Guid.Parse("A08E7253-3BE9-4A2B-85CD-FAC0BA0329BB");
        lookupView.FetchXml = AccountFetchFilter();
        lookupView.LayoutXml = AccountGridFilter();
        lookupView.ObjectTypeCode = "1";
        return lookupView;
    }

    public string AccountFetchFilter()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<fetch version='1.0' output-format='xml-platform' mapping='logical'>");
        sb.Append("<entity name='account'>");
        sb.Append("<attribute name='name' />");
        sb.Append("<attribute name='address1_fax' />");
        sb.Append("<attribute name='accountid' />");
        sb.Append("<attribute name='primarycontactid' />");
        sb.Append("<filter>");
        sb.Append("<condition attribute='accountid' operator='eq' value='3e883019-dd63-e211-853e-005056a64693' />");
        sb.Append("</filter>");
        sb.Append("</entity>");
        sb.Append("</fetch>");
        return sb.ToString();
    }

public string AccountGridFilter()
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>");
        sb.Append("<row name='result' id='accountid'>");
        sb.Append("<cell name='name' width='300' />");
        sb.Append("<cell name='address1_fax' width='100' />");
        sb.Append("<cell name='accountid' width='100' />");
        sb.Append("<cell name='primarycontactid' width='150' />");
        sb.Append("</row>");
        sb.Append("</grid>");
        return sb.ToString();
    }
what i am doing wrong?
Coordinator
Feb 28, 2013 at 4:51 PM
The above code seems to be correct. Do you see the view added to the view list when you open the lookup? or do you get any errors?
sorry I'm not able to tell what could be the problem from the above information.
Mar 1, 2013 at 7:01 AM
i don't get any error bu i cant see filtered data in lookup control. there is only less filter data.

you can see javascript debug code and sended paramaters below code ;

                    oArg = {
                        items: null,
                        customViews: null, 
                        setCustomView: function (viewId, entityName, viewDisplayName, fetchXml, layoutXml) { 


                            customView = {
                                recordType: entityName,
                                id: viewId,
                                name: viewDisplayName,
                                fetchXml: fetchXml,
                                layoutXml: layoutXml
                            };
                            this.customViews=new Array();
                            this.customViews[0] = customView;
                        },

                        setLookupItems: function (ids, names, type) {

                            var idArr = ids.split('|');
                            var nameArr = names.split('|');
                            this.items=new Array();
                            for (var i = 0; i < idArr.length; i++) {
                                if (idArr[i].length >= 32) {
                                    this.items[i] = {
                                        oid: idArr[i],
                                        outerText: nameArr[i],
                                        oType: type,
                                        getAttribute: function (value) {
                                            switch (value) {
                                                case 'oid':
                                                    {
                                                        return this.oid;
                                                    }
                                                case 'otype':
                                                    {
                                                        return this.oType;
                                                    }
                                                default:
                                                    {
                                                        return null;
                                                    }
                                            }
                                        }
                                    };
                                }
                            }
                        }
                    };

                    function fun1() {

debugger;
                        oArg.setLookupItems("", "", "1");
                        if(true){
                            oArg.setCustomView("{B9C7B1FE-55BB-43E6-BA72-5A9096AB55FC}","1","Account Set Screen","<fetch version='1.0' output-format='xml-platform' mapping='logical'><entity name='account'><attribute name='name' /><attribute name='address1_fax' /><attribute name='accountid' /><attribute name='primarycontactid' /><filter><condition attribute='accountid' operator='eq' value='3e883019-dd63-e211-853e-005056a64693' /></filter></entity></fetch>","<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'><row name='result' id='accountid'><cell name='name' width='300' /><cell name='address1_fax' width='100' /><cell name='accountid' width='100' /><cell name='primarycontactid' width='150' /></row></grid>");
                        }

                        var lookupItems = window.showModalDialog('http://crmtest.com/Test/_controls/lookup/lookupinfo.aspx?AllowFilterOff=1&DefaultType=1&DisableQuickFind=0&DisableViewPicker=0&LookupStyle=Single&rDependAttr=incident.bbs_talepadresi&ShowNewButton=1&ShowPropButton=1&browse=0&objecttypes=1&defaultViewId=%7BB9C7B1FE-55BB-43E6-BA72-5A9096AB55FC%7D', oArg, 'resizable:yes;');
                        if (lookupItems != window.undefined)
                            var returnValue = new Array(lookupItems.items.length);
                        if (lookupItems != window.undefined) {
                            for (i = 0; i < lookupItems.items.length; i++) {
                                returnValue[i] = new Array(2);
                                returnValue[i][0] = lookupItems.items[i].id;
                                returnValue[i][1] = lookupItems.items[i].name;
                            }
                        }
                        return returnValue;
                    } fun1();