Hi, I have a custom lookup field (connects with Contacts) in the Account's form. I want to get all contacts in the lookup view which parentcustomerid coincides with the account's name. Here is my code:
//////////////////////////////////////////////
function a1() {
var account_name = Xrm.Page.getAttribute("name").getValue();
var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}"; //Random GUID
var entityName = "contact";
var viewDisplayName = "custom view for contacts";
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='contact'>" +
"<attribute name='fullname' />" +
"<attribute name='parentcustomerid' />" +
"<attribute name='telephone1' />" +
"<attribute name='emailaddress1' />" +
"<attribute name='jobtitle' />" +
"<attribute name='contactid' />" +
"<order attribute='fullname' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='parentcustomerid' operator='eq' value='" + account_name + "' />" +
// "<condition attribute='fullname' operator='like' value='Abc%' />" +
"</filter>" +
"</entity>" +
"</fetch>";
var layoutXml = "<grid name='resultset' object='1' jump='name' select='1' icon='1' preview='1'>" +
"<row name='result' id='contactid'>" +
"<cell name='fullname' width='300' />" +
"<cell name='parentcustomerid' width='300' />" +
"<cell name='telephone1' width='150' />" +
"<cell name='emailaddress1' width='100' />" +
"<cell name='jobtitle' width='100' />" +
"</row>" +
"</grid>";
Xrm.Page.getControl("new_head").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
Please help me to understand why it does not work.
Thanks in advance
*This post is locked for comments