Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Acumatica 使用graph对象将记录插入AP账单和调整单_Acumatica - Fatal编程技术网

Acumatica 使用graph对象将记录插入AP账单和调整单

Acumatica 使用graph对象将记录插入AP账单和调整单,acumatica,Acumatica,我有自定义代码,可以使用登录到另一家公司的web服务(我同意Cludge解决方案)将记录插入到另一家公司的账单和调整中。这很好,但由于需要创建的记录数量太多,速度可能会有点慢 我现在尝试使用账单和调整图对象(APInvoiceEntry)和dac(APInvoice和APTran)来做相同的输入。我遇到了使用web服务方法没有收到的错误。在界面中,当您输入某些字段时,其他字段将默认。我想知道当您使用图形插入记录时是否会发生相同的操作。如果不是,那么我假设我必须填充DAC中的每个字段,而不依赖接口

我有自定义代码,可以使用登录到另一家公司的web服务(我同意Cludge解决方案)将记录插入到另一家公司的账单和调整中。这很好,但由于需要创建的记录数量太多,速度可能会有点慢

我现在尝试使用账单和调整图对象(APInvoiceEntry)和dac(APInvoice和APTran)来做相同的输入。我遇到了使用web服务方法没有收到的错误。在界面中,当您输入某些字段时,其他字段将默认。我想知道当您使用图形插入记录时是否会发生相同的操作。如果不是,那么我假设我必须填充DAC中的每个字段,而不依赖接口的默认属性。这是正确的假设吗?我遇到的错误对我来说没有多大意义,例如:

Error: An error occurred during processing of the field Vendor value 2359 Error: PayAccountID '1931' cannot be found in the system. Please verify whether you have proper access rights to this object.
不确定为什么PayAccountID会成为问题,因为系统中确实存在此特定值“2359”

下面是我目前正在尝试使用graph对象执行的一个示例:

            APInvoiceEntry apgraph = null;
            APInvoice apinvoice = null;
            APTran aptran = null;

            //Get the dataset:
             PXResultset<xvwInterCompanyProcess> res = PXSelect<xvwInterCompanyProcess,
                                                       Where<xvwInterCompanyProcess.origRefNbr, Equal<Required<ARInvoice.refNbr>>>>.Select(new PXGraph(), arinvoice.RefNbr);

            using (PXLoginScope ls = new PXLoginScope("InterCompany@Canada"))
            {
                foreach (PXResult<xvwInterCompanyProcess> rec in res)
                {

                    xvwInterCompanyProcess icp = (xvwInterCompanyProcess)rec;

                    //Save if the RefNbr has changed - unless it's the first record...
                    if (icp.OrigRefNbr != LastRefNbr)
                    {
                        //Save if it's the next header level record - but not if it's the first time through...
                        if (Counter > 0) apgraph.Persist();

                        //Create a new instance of the AP Bills screen graph..
                        apgraph = PXGraph.CreateInstance<APInvoiceEntry>();

                        //Create new header DAC and add the header records...
                        apinvoice = new APInvoice();
                        apinvoice.DocType = icp.DocType;  //apDocType;
                        apgraph.Document.Insert(apinvoice);

                        apinvoice.DocDate = icp.DocDate;
                        apinvoice.InvoiceNbr = icp.VendorRef;
                        apinvoice.DocDesc = icp.Description;
                        apinvoice.BranchID = 6;
                        apinvoice.CuryID = "USD";

                        //Get the Vendor ID from the Vendor CD ("ZINTERPAY")...
                        BAccount bacct = (BAccount)PXSelect<BAccount, Where<BAccount.acctCD, Equal<Constants.zinterpay>>>.Select(new PXGraph<ARDocumentRelease>());
                        apinvoice.VendorID = bacct.BAccountID;

                        //Insert the header (APInvoice) record into the AP Bills graph object..
                        apgraph.Document.Update(apinvoice);
                        apgraph.Persist();
                     }
                     //...create tran level records (code left out)
                     LastRefNbr = icp.OrigRefNbr;                        
                     Counter++;
                 }
             }
APInvoiceEntry apgraph=null;
APInvoice APInvoice=null;
APTran APTran=null;
//获取数据集:
PXResultset res=PXSelect.Select(新建PXGraph(),arinvoice.RefNbr);
使用(PXLoginScope ls=新PXLoginScope(“InterCompany@Canada"))
{
foreach(PXResult rec以res表示)
{
XVW公司间过程icp=(XVW公司间过程)rec;
//如果RefNbr已更改,则保存-除非它是第一条记录。。。
如果(icp.OrigRefNbr!=LastRefNbr)
{
//如果是下一个标题级别的记录,则保存-但如果是第一次通过,则不保存。。。
如果(计数器>0)apgraph.Persist();
//创建AP账单屏幕图的新实例。。
apgraph=PXGraph.CreateInstance();
//创建新的标头DAC并添加标头记录。。。
apinvoice=新apinvoice();
apinvoice.DocType=icp.DocType;//apDocType;
apgraph.Document.Insert(apinvoice);
apinvoice.DocDate=icp.DocDate;
apinvoice.InvoiceNbr=icp.VendorRef;
apinvoice.DocDesc=icp.说明;
apinvoice.BranchID=6;
apinvoice.CuryID=“美元”;
//从供应商CD(“ZINTERPAY”)获取供应商ID。。。
BAccount bacct=(BAccount)PXSelect.Select(new PXGraph());
apinvoice.VendorID=bacct.BAccountID;
//将标题(APInvoice)记录插入AP账单图形对象。。
apgraph.Document.Update(apinvoice);
apgraph.Persist();
}
//…创建传输级别记录(代码遗漏)
LastRefNbr=icp.OrigRefNbr;
计数器++;
}
}

为了澄清错误消息,系统在处理分配给供应商字段的2359时,无法在系统中找到PayAccountID“1931”

错误可能由两种原因引起:

  • apgraph.Document.Insert(apinvoice)
    的结果没有分配回apinvoice变量

  • 由于系统将在更新VendorLocationID后重新分配默认BranchID,因此您应该订阅APInvoice.BranchID FieldDefaulting处理程序,以便在特定branch下创建AP发票

  • 以下是在特定分支下创建AP发票的更新代码片段:

    var apgraph = PXGraph.CreateInstance<APInvoiceEntry>();
    apgraph.FieldDefaulting.AddHandler<APInvoice.branchID>((s, e) =>
    {
        e.NewValue = 17;
        e.Cancel = true;
    });
    
    var apinvoice = new APInvoice();
    apinvoice.DocType = APDocType.Invoice;
    apinvoice = apgraph.Document.Insert(apinvoice);
    
    apinvoice.DocDate = DateTime.Now;
    apinvoice.InvoiceNbr = "0!23!";
    apinvoice.DocDesc = "Demo StackOverflow Bill";
    
    BAccountR bacct = (BAccountR)PXSelect<BAccountR,
        Where<BAccountR.acctCD, Equal<Required<BAccountR.acctCD>>>>
        .Select(apgraph, "AEROCOREBE");
    apinvoice.VendorID = bacct.BAccountID;
    
    apgraph.Document.Update(apinvoice);
    apgraph.Actions.PressSave();
    
    var apgraph=PXGraph.CreateInstance();
    apgraph.FieldDefaulting.AddHandler((s,e)=>
    {
    e、 新值=17;
    e、 取消=真;
    });
    var apinvoice=新的apinvoice();
    apinvoice.DocType=APDocType.Invoice;
    apinvoice=apgraph.Document.Insert(apinvoice);
    apinvoice.DocDate=DateTime.Now;
    apinvoice.InvoiceNbr=“0!23!”;
    apinvoice.DocDesc=“演示StackOverflow Bill”;
    BAccountR bacct=(BAccountR)PXSelect
    .选择(apgraph,“AEROCOREBE”);
    apinvoice.VendorID=bacct.BAccountID;
    apgraph.Document.Update(apinvoice);
    apgraph.Actions.PressSave();
    
    能否用代码片段更新您的问题?完成。我没有包括Web服务代码,因为它是有效的