Acumatica 创建现有客户的新副本
我需要创建新客户,主要是复制一个选定的客户,并修改一些与自定义流程相关的字段。 在定制流程之外,作为初步尝试,看看是否可以复制客户,我有以下几点:Acumatica 创建现有客户的新副本,acumatica,Acumatica,我需要创建新客户,主要是复制一个选定的客户,并修改一些与自定义流程相关的字段。 在定制流程之外,作为初步尝试,看看是否可以复制客户,我有以下几点: public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint> { public PXAction<Customer> copyTest; [PXProcessButton] [PXUIField(DisplayName =
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
public PXAction<Customer> copyTest;
[PXProcessButton]
[PXUIField(DisplayName = "Copy Test")]
protected virtual void CopyTest()
{
var customer = Base.BAccount.Current;
var graph = PXGraph.CreateInstance<CustomerMaint>();
var cache = graph.BAccount.Cache;
// Set field Defaults using CustomerMaint.CopyAccounts method
graph.CopyAccounts(cache, customer);
// Create new copy of current Customer
var copyCustomer = (Customer)cache.CreateCopy(customer);
// Modify key values
copyCustomer.AcctCD = "COPY " + customer.AcctCD;
copyCustomer.BAccountID = null;
// Prevent "Customer Class Changed -- update Defaults?" dialog
cache.SetStatus(copyCustomer, PXEntryStatus.Inserted);
// Insert into cache
// *** Exception occurs here ***
copyCustomer = (Customer)cache.Insert(copyCustomer);
// Modify additional fields as necessary by custom process
// ...
// Persist to database
graph.Save.Press();
}
}
我从customerMain
图形的salessperson.Insert(speperson)
点的CustomerClassDefaultInserting
函数中找到了这一点。此函数似乎正在尝试为指定客户类别的默认销售人员创建CustSalesopers记录
这是复制客户的正确途径还是有更好的方法?或者在插入新客户时如何处理异常?复制客户的问题不仅仅是复制一个对象。需要为客户复制许多对象 我复制了你的代码并执行了它。我注释掉了CopyAccounts,因为我认为它将在克隆对象上调用,而不是在现有客户上调用 我收到的下一个错误是错误:处理字段默认位置值8068时出错错误:在系统中找不到默认位置“8068” 这是因为从客户记录中克隆了其他外键字段。DefLocationID是客户的默认位置。它也在尝试设置这些键,但由于选择器上的限制而无法设置,要求位置与记录相同。DefAddressID、defactId和其他关键字段的操作方式相同
因此,要完成这项工作,您需要检查Customer/BAccount上可能设置的所有外键,然后复制这些对象,并将它们设置为适当的DAC。有些信息可能不需要复制,所以我只需要将这些关键字段设置为空,然后复制所需的内容。嘿,Nickolas Hook,就像KRichardson指出的那样,由于所有PK/FK约束,您不能只复制数据,您将不得不单独执行所有操作 另一种方法是为父级提取数据
Error: An error occurred during processing of the field CustomerClassID: Value cannot be null.
Parameter name: key