开箱即用Extend To Vendor用操作不能在导入场景中使用,因为它会重定向到包含预填充数据的供应商屏幕,并且用户必须手动保存供应商。
在下面的代码片段中,我们正在创建一个新的隐藏操作,该操作调用基本“将客户扩展到供应商”操作并保留供应商数据,而不是重定向到供应商屏幕。
using System;
using System.Collections;
using PX.Data;
using PX.Objects.AR;
namespace PXExtendCustomerToVendorExtPkg
{
public class CustomerMaintPXExt : PXGraphExtension<CustomerMaint>
{
public PXAction<Customer> extendToVendorPXExt;
[PXUIField(DisplayName = "Extend To Vendor Ext",
MapEnableRights = PXCacheRights.Select,
MapViewRights = PXCacheRights.Select,
Visible = false)]
[PXButton]
public virtual IEnumerable ExtendToVendorPXExt(PXAdapter adapter)
{
try
{
if (Base.extendToVendor.GetEnabled())
Base.extendToVendor.Press();
}
catch (Exception ex)
{
if (ex is PXRedirectRequiredException)
{
PXRedirectRequiredException rdEx = (PXRedirectRequiredException)ex;
rdEx.Graph.Actions.PressSave();
}
else
throw ex;
}
return adapter.Get();
}
}
}
Run Code Online (Sandbox Code Playgroud)
发布定制后,修改Import Scenario(CustomersSM206025)并Extend To Vendor Ext在保存操作后添加新操作。