如何在篩選聯絡人時控制只能篩選上層客戶的聯絡人.

function OnAfterAccountSelect()
{

 var customerlookup=crmForm.all.customerid;
          
    var contactLookup  = crmForm.all.new_contactid;
//    if( contactLookup.DataValue != null ) {return;}
    //alert(displayProperty(customerlookup.items[0]));
    if (customerlookup.DataValue!=null)
     crmForm.all.new_contactid.Disabled=false;
    else
      crmForm.all.new_contactid.Disabled=true;

     contactLookup.AutoResolve = 1;
    contactLookup.lookupbrowse=1;
    primaryContact = customerlookup.items[0].keyValues.primarycontactid;
       
        contactDiv = document.all.new_contactid_d.getElementsByTagName("DIV")[0];

    contactDiv.innerText = primaryContact.value;
    contactLookup.Lookup( true , true , primaryContact.value , true );
     // Pass fetch xml through search value parameter
    contactLookup.AddParam("search",
     "<fetch mapping='logical'><entity name='contact'>"
    + "<filter><condition attribute='parentcustomerid' operator='eq' value='"
    + customerlookup.items[0].id
    + "' /></filter></entity></fetch>");

}
function OnCrmPageLoad()
{
  var customerlookup=crmForm.all.customerid;
    crmForm.all.customerid.attachEvent( "onafterselect" , OnAfterAccountSelect );
   if (customerlookup.DataValue==null)
    crmForm.all.new_contactid.Disabled=true;
    
}

OnCrmPageLoad();

 

 

2.CRMWeb\_controls\lookup目錄的lookupsingle.aspx檔案,修改如下

<script runat="server">

protected override void OnLoad( EventArgs e )
{
      base.OnLoad(e);
      crmGrid.PreRender += new EventHandler( crmgrid_PreRender );
}

void crmgrid_PreRender( object sender , EventArgs e )
{
    // As we don't want to break any other lookups, ensure that we use workaround only if
    // search parameter set to fetch xml.
    if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith("<fetch"))
    {
        crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);

        // searchvalue needs to be removed as it's typically set to a wildcard '*'
        crmGrid.Parameters.Remove("searchvalue");

        // Icing on a cake - ensure that user cannot create new contact outside of the account
        // and then select it.
        this._showNewButton = false;
    }
}

</script>

4.

你可能感兴趣的:(控制)