Acumatica API:使用CR303000.Actions.ConverToCustomer
我正在尝试使用Acumatica API将Acumatica 5.20.2067上的业务帐户转换为客户。我使用的代码是基于。将业务帐户转换为客户似乎比转换潜在客户更简单,因为转换业务帐户不会弹出对话框。但是,我尝试了两种方法,一种产生错误,另一种创建完全独立的客户记录,而不是转换现有的业务帐户 根据另一篇文章中关于转换潜在客户的代码,以下是我认为应该有效的代码:Acumatica API:使用CR303000.Actions.ConverToCustomer,acumatica,Acumatica,我正在尝试使用Acumatica API将Acumatica 5.20.2067上的业务帐户转换为客户。我使用的代码是基于。将业务帐户转换为客户似乎比转换潜在客户更简单,因为转换业务帐户不会弹出对话框。但是,我尝试了两种方法,一种产生错误,另一种创建完全独立的客户记录,而不是转换现有的业务帐户 根据另一篇文章中关于转换潜在客户的代码,以下是我认为应该有效的代码: Public Function ConvertBusinessAccountToCustomer(ByVal baID As Stri
Public Function ConvertBusinessAccountToCustomer(ByVal baID As String, ByVal firstName As String, ByVal LastName As String)
Dim CR303000 As CR303000Content = m_context.CR303000GetSchema()
m_context.CR303000Clear()
Dim AR303000 As AR303000Content = m_context.AR303000GetSchema()
m_context.AR303000Clear()
' call the Action to convert the BA to a Customer
Dim baKeyVal As Value = CreateValue(CR303000.AccountSummary.BusinessAccount, baID)
Dim updateBACommands As Command() = {baKeyVal, CR303000.Actions.ConverToCustomer}
Dim updateBaResult As CR303000Content() = m_context.CR303000Submit(updateBACommands)
' just like with Lead, the Customer record now needs to be saved
' add other fields required for Customer
Dim customerNameVal As Value = CreateValue(AR303000.CustomerSummary.CustomerName, CreateCustomerFullName(firstName, LastName))
Dim classVal As Value = CreateValue(AR303000.GeneralInfoFinancialSettings.CustomerClass, "DEFAULT")
Dim statementCycleVal As Value = CreateValue(AR303000.GeneralInfoFinancialSettings.StatementCycleID, "ENDOFMONTH")
Dim statementTypeVal As Value = CreateValue(AR303000.BillingSettingsPrintAndEmailSettings.StatementType, "Open Item")
Dim cashDiscountAccountVal As Value = CreateValue(AR303000.GLAccountsCashDiscountAccount.CashDiscountAccount, "10103")
Dim creditVerificationVal As Value = CreateValue(AR303000.GeneralInfoCreditVerificationRulesCreditVerification.CreditVerification, "Disabled")
Dim commandsCustomer As Command() =
{
customerNameVal, classVal, statementCycleVal, statementTypeVal, cashDiscountAccountVal, creditVerificationVal,
AR303000.Actions.Save,
AR303000.CustomerSummary.CustomerID
}
Dim newCustomerContent As AR303000Content() = m_context.AR303000Submit(commandsCustomer)
Dim newCustomerID As String = ""
If newCustomerContent.Length > 0 Then
' this should be exact same as the newBAID, this is just for debugging
newCustomerID = newCustomerContent(0).CustomerSummary.CustomerID.Value
End If
Return newCustomerID
End Function
但结果是,当使用ConvertCustomer操作调用CR303000Submit时,我得到了以下引用默认位置值的错误:
[SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request.
---> PX.Data.PXFieldValueProcessingException: Error: An error occurred while processing the field Default Location value 15497 Error: Default Location '15497' cannot be found in the system.. ---> PX.Data.PXSetPropertyException: Error: DefLocationID '15497' cannot be found in the system.
at PX.Data.PXSelectorAttribute.throwNoItem(String[] restricted, Boolean external, Object value)
at PX.Data.PXSelectorAttribute.FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
at PX.Data.PXCache.OnFieldVerifying(String name, Object row, Object& newValue, Boolean externalCall)
at PX.Data.PXCache`1.a(TNode& A_0)
--- End of inner exception stack trace ---
at PX.Data.PXCache`1.Insert(Object data, Boolean bypassinterceptor)
at PX.Data.PXCache`1.Insert(Object data, Boolean bypassinterceptor)
at PX.Data.PXCache`1.Insert(Object data)
at PX.Data.PXCache`1.Extend[Parent](Parent item)
at PX.Objects.CR.BusinessAccountMaint.ConverToCustomer(PXAdapter adapter)
at PX.Data.PXAction`1.a(PXAdapter A_0)
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Api.SyImportProcessor.SyStep.CommitChanges(Object itemToBypass, PXFilterRow[] targetConditions, PXFilterRow[] filtersForAction)
at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()
at PX.Api.ScreenUtils.Submit(String screenId, Command[] commands, SchemaMode schemaMode, PXGraph& graph, String& redirectContainerView, String& redirectScreen, Boolean mobile, Dictionary`2 viewFilters)
at PX.Api.Services.ScreenService.Submit(String id, IEnumerable`1 commands, SchemaMode schemaMode, Boolean mobile, PXGraph& forceGraph, String& redirectContainerView, String& redirectScreen, Dictionary`2 viewFilters)
at PX.Api.Services.ScreenService.Submit(String id, IEnumerable`1 commands, SchemaMode schemaMode)
at PX.Api.Soap.Screen.ScreenGate.Submit(Command[] commands)
--- End of inner exception stack trace ---]
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Source Error
Line 1555: <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.acumatica.com/generic/CR303000/Submit", RequestNamespace:="http://www.acumatica.com/generic/", ResponseNamespace:="http://www.acumatica.com/generic/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Line 1556: Public Function CR303000Submit(ByVal commands() As Command) As <System.Xml.Serialization.XmlArrayAttribute("SubmitResult"), System.Xml.Serialization.XmlArrayItemAttribute("Content")> CR303000Content()
Line 1557: Dim results() As Object = Me.Invoke("CR303000Submit", New Object() {commands})
Line 1558: Return CType(results(0),CR303000Content())
Line 1559: End Function
[SoapException:System.Web.Services.Protocols.SoapException:服务器无法处理请求。
--->PX.Data.PXFieldValueProcessingException:错误:处理字段默认位置值15497时出错错误:在系统中找不到默认位置“15497”。-->PX.Data.PXSetPropertyException:错误:在系统中找不到DefLocationID“15497”。
在PX.Data.PXSelectorAttribute.throwNoItem(字符串[]受限,布尔外部,对象值)
在PX.Data.PXSelectorAttribute.FieldVerification(PXCache发送方,PXFieldVerifyingEventArgs e)
在PX.Data.PXCache.onfieldVerification(字符串名称、对象行、对象和新值、布尔外部调用)
在PX.Data.PXCache`1.a处(TNode&a_0)
---内部异常堆栈跟踪的结束---
在PX.Data.PXCache`1.Insert处(对象数据,布尔旁路拦截器)
在PX.Data.PXCache`1.Insert处(对象数据,布尔旁路拦截器)
在PX.Data.PXCache`1.Insert处(对象数据)
在PX.Data.PXCache`1.Extend[Parent](父项)
在PX.Objects.CR.BusinessAccountMaint.ConverToCustomer(PXAdapter适配器)上
在PX.Data.PXAction`1.a处(PXAdapter a_0)
在PX.Data.PXAction`1.d_uc.MoveNext()中
在PX.Data.PXAction`1.d_uc.MoveNext()中
在PX.Api.SyImportProcessor.SyStep.CommitChanges(对象项ToByPass、PXFilterRow[]targetConditions、PXFilterRow[]FilterForAction)
在PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()处
在PX.Api.ScreenUtils.Submit(String screenId、Command[]命令、SchemaMode SchemaMode、PXGraph&graph、String&redirectContainerView、String&redirectScreen、Boolean mobile、Dictionary`2视图过滤器)
在PX.Api.Services.ScreenService.Submit(字符串id、IEnumerable`1命令、SchemaMode SchemaMode、Boolean mobile、PXGraph&forceGraph、String&redirectContainerView、String&redirectScreen、Dictionary`2视图过滤器)
在PX.Api.Services.ScreenService.Submit(字符串id,IEnumerable`1命令,SchemaMode SchemaMode)
在PX.Api.Soap.Screen.ScreenGate.Submit(Command[]commands)
---内部异常堆栈跟踪结束---]
System.Web.UI.WebControl.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+35
System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+1724
源错误
第1555行:_
第1556行:公共函数CR303000提交(ByVal commands()作为命令)作为CR303000内容()
第1557行:Dim results()作为Object=Me.Invoke(“CR303000Submit”,New Object(){commands})
第1558行:返回CType(结果(0),CR303000内容()
第1559行:结束函数
我尝试的另一件事是更改CR303000Submit的命令以添加保存操作:
Dim UPDATEBACOMANDS Command()={baKeyVal,CR303000.Actions.ConverToCustomer,CR303000.Actions.Save}
这使我无误地通过了该行,但当我调用AR303000 Submit时,它只是使用不同的客户/业务帐户ID创建了一个单独的客户记录,而不是转换现有的业务帐户。这里有两个问题: 处理字段默认位置值15497时出错错误:在系统中找不到默认位置“15497” 我想这是你的数据问题。使用浏览器登录并手动检查此业务帐户。我想你也会收到同样的错误 转化为客户行动问题 此操作将生成重定向。这是个问题。但有一个解决办法:
- 创建新的自定义项目
- 为图形“BusinessAccountMaint”创建GraphExtension
- 插入下一个代码 使用制度; 使用系统集合; 使用Avalara.AvaTax.Adapter.AvaCert2Service; 使用PX.Common; 使用PX数据; 使用PX.Data.EP; 使用PX.Objects.AP; 使用PX.Objects.CS; 使用PX.Objects.CT; 使用PX.Objects.SO; 使用PX.SM; 使用System.Collections.Generic; 使用PX.Objects; 使用PX.Objects.CR 命名空间PX.Objects.CR { 公共类BusinessAccountMaint_扩展:pxGrapherExtension {
- 此代码将业务帐户转换为客户并立即保存
- 创建新的自定义项目
- 为图形“BusinessAccountMaint”创建GraphExtension
- 插入下一个代码
使用制度;
使用系统集合;
使用Avalara.AvaTax.Adapter.AvaCert2Service;
使用PX.Common;
使用PX数据;
使用PX.Data.EP;
使用PX.Objects.AP;
使用PX.Objects.CS;
使用PX.Objects.CT;
使用PX.Objects.SO;
使用PX.SM;
使用System.Collections.Generic;
使用PX.Objects;
使用PX.Objects.CR
public PXAction<BAccount> convertToCustomerAndSave; // hidden action. Used in API calls [PXUIField(DisplayName = "Convert To Customer And Save", Visible = false, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)] [PXButton(ImageKey = PX.Web.UI.Sprite.Main.Process)] public virtual IEnumerable ConvertToCustomerAndSave(PXAdapter adapter) { try { return Base.ConverToCustomer(adapter); } catch (PXRedirectRequiredException e) // catch redirect exception { (e.Graph as AR.CustomerMaint).Save.Press(); // Save our new customer return adapter.Get(); } } }
static void Main(string[] args) { var client = new ScreenSoapClient(); client.Login("admin", "123"); var baSchema = client.CR303000GetSchema(); var commands = new Command[] { new Value { Value = "MAURICES", LinkedCommand = baSchema.AccountSummary.BusinessAccount }, baSchema.Actions.ConvertToCustomerAndSave // use our new action instead of default }; client.CR303000Submit(commands); }
- 这里有两个问题:
处理字段默认位置值15497时出错错误:在系统中找不到默认位置“15497”
我想这是您的数据问题。使用浏览器登录并手动检查此业务帐户。我想您将收到相同的错误
转化为客户行动问题
此操作会产生重定向。这是一个问题。但有一个解决方案: