Saturday, July 14, 2012

MS CRM 2011: Strange issue with filtered lookup

Today I was working with filtered lookup. Before I had no issues with it but today I faced with strange issue.
var FetchXml = "";
var LayoutXml = "";
Xrm.Page.getControl("Field Name").addCustomView("00010000-0100-0010-0100-010000010001",
    "Entity Logical Name", "View Name", FetchXml, LayoutXml, true);

During testing I have got following error screen:
 
I have started to debug and I have found source of issue:

Issue was in following line

crmGrid.SetParameter("viewtype", o.options[o.selectedIndex].Type);

Solution came easily – view id should contain brackets { and }:

var FetchXml = "";
var LayoutXml = "";
Xrm.Page.getControl("Field Name").addCustomView("{00010000-0100-0010-0100-010000010001}",
    "Entity Logical Name", "View Name", FetchXml, LayoutXml, true);

No comments:

Post a Comment