How to have a custom filtering on lockup using form java script in mscrm 2011: by Srinivas kalwakuntla
function Accountview() {
var account = Xrm.Page.getAttribute('tls_parentaccount');
var accountid;
if (account != null) {
var lookUpObjectValue = account.getValue();
if ((lookUpObjectValue != null)) {
var lookuptextvalue = lookUpObjectValue[0].name;
var accountid = lookUpObjectValue[0].id;
}
if (!IsNull(accountid)) {
var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}";
var entityName = "account";
var viewDisplayName = "Default View For Account";
var fetchXml = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">' +
'<entity name="account">' +
'<attribute name="name" />' +
'<attribute name="sic" />' +
'<attribute name="accountid" />' +
'<attribute name="address1_city" />' +
'<attribute name="telephone1" />' +
'<attribute name="primarycontactid" />' +
'<filter type="and">' +
'<condition attribute="accountid" operator="ne" value="' + accountid + '"/>' +
'</filter>' +
'</entity>' +
'</fetch>';
// build Grid Layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='account' " +
"select='0' " +
"icon='0' " +
"preview='1'>" +
"<row name='result' " +
"id='accountid'>" +
"<cell name='name' " +
"width='200' />" +
"<cell name='primarycontactid' " +
"width='150' />" +
"<cell name='sic' " +
"width='150' />" +
"<cell name='address1_city' " +
"width='150' />" +
"<cell name='telephone1' " +
"width='150' />" +
"</row>" +
"</grid>";
Xrm.Page.getControl("new_newemployer").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
Xrm.Page.getControl("new_previousemployer").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
}
}
}
No comments:
Post a Comment