【问题标题】:Update Delivery Date (Custom Field) in screen Invoices and Memos of Acumatica ERP System using webservices API使用 webservices API 在 Acumatica ERP 系统的屏幕发票和备忘录中更新交货日期(自定义字段)
【发布时间】:2017-08-12 12:53:08
【问题描述】:

我在屏幕发票和备忘录的标题中创建了新的附加字段,请参阅下面的屏幕截图。

下面是 DAC:

#region UsrDeliveryDate
public abstract class usrDeliveryDate : IBqlField{}
  [PXDBDate()]
  [PXUIField(DisplayName="Delivery Date", Visibility = PXUIVisibility.SelectorVisible)]

  public DateTime? UsrDeliveryDate
  {
      get;
      set;
  }

  #endregion

然后我使用下面的代码通过 webservices API 更新了这个交货日期:

try
        {
            sCon.getLoginInv(context);
            AR301000Content kon = context.AR301000GetSchema();
            var command2 = new Command[]
            {
                kon.InvoiceSummary.ReferenceNbr,
                kon.InvoiceSummary.Type,
                kon.InvoiceSummary.CustomerOrder,
                kon.InvoiceSummary.DeliveryDate
                //kon.InvoiceSummary.DueDate,
                //kon.InvoiceSummary.Customer
            };
            var filter = new Filter[]
            {
                new Filter()
                {
                    Field = new Field
                    {
                        FieldName = kon.InvoiceSummary.CustomerOrder.FieldName,
                        ObjectName = kon.InvoiceSummary.CustomerOrder.ObjectName
                    },
                    Value = "CNSE/17-III/00023"
                }
            };
            var result = context.AR301000Export(command2, filter, 0, false, true);
            foreach (var ax in result)
            {
                DeliveryDateClass delivDate = new DeliveryDateClass();
                delivDate.refNbr = ax[0].ToString().Trim();
                delivDate.type = ax[1].ToString().Trim();
                delivDate.custOrder = ax[2].ToString().Trim();
                delivDate.deliveryDate = ax[3].ToString().Trim();
                //delivDate.dueDate = ax[4].ToString().Trim();
                //delivDate.customerID = ax[5].ToString().Trim();

                kon.InvoiceSummary.Type.LinkedCommand = null;
                kon.InvoiceSummary.Type.Commit = false;
                var command = new Command[]
                {
                        new Value { Value = delivDate.type, LinkedCommand = kon.InvoiceSummary.Type},
                        new Value { Value = delivDate.refNbr, LinkedCommand = kon.InvoiceSummary.ReferenceNbr},

                        new Key
                        {
                            ObjectName = kon.InvoiceSummary.DeliveryDate.ObjectName,
                            FieldName = kon.InvoiceSummary.DeliveryDate.FieldName,
                            Value = "='" + delivDate.deliveryDate + "'"
                        },

                        new Value { Value = "4/20/2017", LinkedCommand = kon.InvoiceSummary.DeliveryDate },
                        kon.Actions.Save
                };
                context.AR301000Submit(command);
                sCon.getLogout(context, contextUntyped);
            }
            return "Update Success";
        }
        catch (Exception x)
        {
            MessageBox.Show(x.Message);
            return "FAILED";
        }
        finally
        {
            sCon.getLogout(context, contextUntyped);
        }

我会在下面更新此交易的交货日期。

但我有如下错误消息。

如果我在 Doc Type = "Invoice" 的交易中使用相同的代码,它可以工作,但对于 Doc Type = Credit Memo 的交易,它不起作用。

【问题讨论】:

    标签: c# web-services api acumatica erp


    【解决方案1】:

    通过将 LinkedCommand 设置为 null 并将 Commit 设置为 falseType 字段的原因是什么/em>?

    kon.InvoiceSummary.Type.LinkedCommand = null;
    kon.InvoiceSummary.Type.Commit = false;
    

    以下示例可以正常工作,无需对 Type 字段进行任何修改:

    Screen context = new Screen();
    context.CookieContainer = new System.Net.CookieContainer();
    context.Url = "http://localhost/StackOverflow/Soap/AR301000.asmx";
    context.Login(username, password);
    try
    {
        Content invoiceSchema = PX.Soap.Helper.GetSchema<Content>(context);
        var commands = new Command[]
        {
            new Value
            {
                LinkedCommand = invoiceSchema.InvoiceSummary.Type,
                Value = "Credit Memo"
            },
            new Value
            {
                LinkedCommand = invoiceSchema.InvoiceSummary.ReferenceNbr,
                Value = "AR004776"
            },
            new Value
            {
                LinkedCommand = invoiceSchema.InvoiceSummary.Description,
                Value = "Test"
            },
            invoiceSchema.Actions.Save
        };
        context.Submit(commands);
    }
    finally
    {
        context.Logout();
    }
    

    【讨论】:

    • 感谢鲁斯兰,它有效。我只是清除 kon.InvoiceSummary.Type.LinkedCommand = null;和 kon.InvoiceSummary.Type.Commit = false;但是为什么如果我在类型字段中使用修改,它可以使用 DocType = Invoice,但它不适用于除“Invoice”之外的所有类型?
    • 因为发票是默认类型。
    • 明白了。感谢您的回答鲁斯兰 :)
    • 嗨,Ruslan,我真的很抱歉再次提到你。但是我有一个紧急问题,如果您不介意,请您在这个问题的链接中给我参考以解决我的问题:stackoverflow.com/questions/44195954/…我已经在等待任何问题,但没有答案可以解决这个问题。非常感谢您愿意为我提供解决此问题的参考资料。
    猜你喜欢
    • 2021-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    相关资源
    最近更新 更多