如何通过客户导入场景自动扩展到供应商
How to Automate Extend To Vendor via Customer Import Scenario
如何在Acumatica中通过Import Scenario引入同时分类为Customer和Vendor的企业账户?[=10=]
开箱即用的 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();
}
}
}
发布自定义后,为 Customers
(SM206025) 修改 Import Scenario
并在保存操作后添加新的 Extend To Vendor Ext
操作。
DChhapgar 的解决方案非常好。以下是适用于 Acumatica 21R1 的修改版本,因为 Acumatica 进行了一些修改:分别为 ExtendToCustomer
和 ExtendToVendor
PXGraphExtension(s) 创建于:
App_Data\CodeRepository\PX.Objects\Extensions\ExtendBAccount
因此需要先申请延期var graphExt = Base.GetExtension<ExtendToCustomer>();
。下面的代码用于从 BusinessAccount 扩展到 customer,它也在保存之前对 customer 进行了一些更改(在代码中注释)。扩展到供应商的概念相同。
using PX.Data;
using PX.Objects.AR;
using System;
using System.Collections;
using static PX.Objects.CR.BusinessAccountMaint;
namespace PX.Objects.CR
{
public class IBBusinessAccountMaintExt : PXGraphExtension<BusinessAccountMaint>
{
public PXAction<BAccount> extendToCustomerPXExt;
[PXUIField(DisplayName = "Extend As Customer Ext", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
[PXButton]
public virtual IEnumerable ExtendToCustomerPXExt(PXAdapter adapter)
{
try {
var graphExt = Base.GetExtension<ExtendToCustomer>();
if (graphExt.extendToCustomer.GetEnabled()) { graphExt.extendToCustomer.Press(); }
} catch (Exception ex) {
if (ex is PXRedirectRequiredException) {
PXRedirectRequiredException rdEx = (PXRedirectRequiredException)ex;
// If there is a need to make changes in new Graph
CustomerMaint editCustomer = (CustomerMaint)rdEx.Graph;
//editCustomer.CurrentCustomer.SetValueExt<Customer.paymentsByLinesAllowed>(editCustomer.BAccount.Current, true);
rdEx.Graph.Actions.PressSave();
} else
throw ex;
}
return adapter.Get();
}
}
}
如何在Acumatica中通过Import Scenario引入同时分类为Customer和Vendor的企业账户?[=10=]
开箱即用的 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();
}
}
}
发布自定义后,为 Customers
(SM206025) 修改 Import Scenario
并在保存操作后添加新的 Extend To Vendor Ext
操作。
DChhapgar 的解决方案非常好。以下是适用于 Acumatica 21R1 的修改版本,因为 Acumatica 进行了一些修改:分别为 ExtendToCustomer
和 ExtendToVendor
PXGraphExtension(s) 创建于:
App_Data\CodeRepository\PX.Objects\Extensions\ExtendBAccount
因此需要先申请延期var graphExt = Base.GetExtension<ExtendToCustomer>();
。下面的代码用于从 BusinessAccount 扩展到 customer,它也在保存之前对 customer 进行了一些更改(在代码中注释)。扩展到供应商的概念相同。
using PX.Data;
using PX.Objects.AR;
using System;
using System.Collections;
using static PX.Objects.CR.BusinessAccountMaint;
namespace PX.Objects.CR
{
public class IBBusinessAccountMaintExt : PXGraphExtension<BusinessAccountMaint>
{
public PXAction<BAccount> extendToCustomerPXExt;
[PXUIField(DisplayName = "Extend As Customer Ext", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = false)]
[PXButton]
public virtual IEnumerable ExtendToCustomerPXExt(PXAdapter adapter)
{
try {
var graphExt = Base.GetExtension<ExtendToCustomer>();
if (graphExt.extendToCustomer.GetEnabled()) { graphExt.extendToCustomer.Press(); }
} catch (Exception ex) {
if (ex is PXRedirectRequiredException) {
PXRedirectRequiredException rdEx = (PXRedirectRequiredException)ex;
// If there is a need to make changes in new Graph
CustomerMaint editCustomer = (CustomerMaint)rdEx.Graph;
//editCustomer.CurrentCustomer.SetValueExt<Customer.paymentsByLinesAllowed>(editCustomer.BAccount.Current, true);
rdEx.Graph.Actions.PressSave();
} else
throw ex;
}
return adapter.Get();
}
}
}