RE: Opening lookup view dynamically
var Department = parent.Xrm.Page.getControl("com_department").getAttribute().getValue()[0].id;
var lookupOptions = {};
lookupOptions.allowMultiSelect = false;
lookupOptions.defaultEntityType = "contact";
lookupOptions.entityTypes = ["contact"];
lookupOptions.filters = [{
filterXml: "<filter type='and'><condition attribute='com_primarydepartmentid' operator='eq' uitype='account' value='" + Department + "' /></filter>",
entityLogicalName: "contact"
}];
Xrm.Utility.lookupObjects(lookupOptions).then(
function (result) {
if (result != undefined && result.length > 0) {
contactlookup = new Object();
if (result.length > 0) {
for (var i = 0; i < result.length; i++) {
entityreferencecontact = result[0].name;
contactlookup.LogicalName = result[0].entityType;
contactlookup.Id = result[0].id;
}
}
}
},
function (error) { }
);