posts - 48,  comments - 207,  trackbacks - 2

      在微软CRM4.0标准功能中报价单、订单、发票实体实现了“查找地址”功能,可以把报价单、订单、发票关联潜在客户的地址信息带到报价单、订单、发票的账单邮寄地址或者送货地址,避免手动重复录入,提高工作效率,功能如下图:

 

 

 

 

 

对于自定义实体,默认并不提供“查找地址”功能,我们可以通过客户化的方式来实现此功能。

步骤一、通过ISV.config增加 “查找地址”按钮,代码如下:

      <Entities>
        <Entity name="new_shipping">
          <ToolBar ValidForCreate="1" ValidForUpdate="1">
            <Button JavaScript="LookupAddress();" PassParams="1" WinMode="2">
              <Titles>
                <Title LCID="2052" Text="查找地址..." />
              </Titles>
              <ToolTips>
                <ToolTip LCID="2052" Text="查找地址..." />
              </ToolTips>
            </Button>
          </ToolBar>
        </Entity>
         .
         .
         .
         .
         .
         .

步骤二、在new_shipping的onload事件中 重写 LookupAddress()方法,代码如下:

window.LookupAddress = function()  
{
                var aoItems = crmForm.all.new_accountid.DataValue;
                if (IsNull(aoItems))
                {
                                alert("必须先提供订单顾客的值才能查找地址");
                                var sArg = crmForm.GetLabel(crmForm.all.new_accountid);
                                alert( formatString(LOCID_PROVIDE_VALUE_ADDRESS, sArg));
                                return;
                } 

                var o = openStdDlg(prependOrgName("/sfa/quotes/dlg_lookupaddress.aspx?headerForm=1&parentType=" + aoItems[0].type + "&parentId=" + aoItems[0].id + "&willCall=0"), "LookupAddress", 500, 330, true);
                if (o)
                {
                                SetBillTo(o);
                                SetShipTo(o, false, parseInt(crmFormSubmit.crmFormSubmitObjectType.value, 10));
                }
}

window.SetBillTo = function(o)
{
	with (crmForm)
	{
		if (o.BillTo)
		{
			new_billto_name.value                 = o.Address.Name;
			new_billto_line1.value                  = o.Address.Line1;
			new_billto_city.value                   = o.Address.City;
			new_billto_stateorprovince.value   = o.Address.StateOrProvince;
			new_billto_postalcode.value          = o.Address.PostalCode;
			new_billto_country.value              = o.Address.Country;
			new_billto_telephone.value           = o.Address.Telephone;
			new_billto_fax.value                    = o.Address.Fax;
			new_billto_contactname.value       = o.Address.ContactName;
		}
	}
}


window.SetShipTo = function(o, isDetail, iObjectType)
{
	with (crmForm.all)
	{
		if (o.ShipTo)
		{
			new_shipto_name.value                = o.Address.Name;
			new_shipto_line1.value                 = o.Address.Line1;
			new_shipto_city.value                  = o.Address.City;
			new_shipto_stateorprovince.value  = o.Address.StateOrProvince;
			new_shipto_postalcode.value         = o.Address.PostalCode;
			new_shipto_country.value             = o.Address.Country;
			new_shipto_telephone.value           = o.Address.Telephone;
			new_shipto_fax.value                    = o.Address.Fax;
			new_shipto_contactname.value       = o.Address.ContactName;
		}
	}
}

发布后功能如下图:

 

posted on 2010-08-10 17:56  Batistuta Cai  阅读(1795)  评论(2编辑  收藏