I’m trying to filter the opportunity products based on another custom field on the opportunity line item form. However; I’m trying to get this much simpler example to work below first, which should filter any products with the name like ‘Abc%’. Although, I’m getting an error that states “Unable to get property 'addCustomView' of undefined or null reference”. Any help would be appreciated.
var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}"; //Random GUID
var entityName = "product";
var viewDisplayName = "Products beginning with Abc";
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='product'>" +
"<attribute name='name' />" +
"<condition attribute='name' operator='like' value='Abc%' />" +
"</filter>" +
"</entity>" +
"</fetch>";
var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +
"<cell name='name' width='300' />" +
"</row>" +
"</grid>";
Xrm.Page.getControl("productid").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);