HI,
I have one Email field and contact lookup in concern form. i need to filter the lookup based on the email.i am using below code. but the values are not coming in the lookup and if we click on the lookup it is giving error saying that contact system admin. on change of email i am refreshing the form and i am calling this function in onLoad. can any one please help on this.
function onLoad() {
Xrm.Page.getControl("sandeep_customername").addPreSearch(function () {
addLookupFilter();
});
}
function addLookupFilter() {
try {
var email = Xrm.Page.getAttribute("sandeep_emailid").getValue();
if (email != null) {
var filter = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='account'>"
+ "<attribute name='name'/>"
+ "<attribute name='telephone1'/>"
+ "<attribute name='contactid'/>"
+ "<attribute name='emailaddress1'/>"
+ "<order descending='false' attribute='name'/>"
+ "<filter type='and'>"
+ "<condition attribute='sandeep_emailid' operator='like' value='" + email + "'/>"
+ "</filter></entity></fetch>";
Xrm.Page.getControl("sandeep_customername").addCustomFilter(filter);
}
}
catch (ex) {
throw ex
}
}
Thanks.