使用网络服务更新 Acumatica ERP 系统屏幕发票和备忘录中的交货日期(自定义字段)API
Update Delivery Date (Custom Field) in screen Invoices and Memos of Acumatica ERP System using webservices API
我在 header 屏幕发票和备忘录中创建了新的附加字段,请参考下面的屏幕截图。
下面这个是DAC:
#region UsrDeliveryDate
public abstract class usrDeliveryDate : IBqlField{}
[PXDBDate()]
[PXUIField(DisplayName="Delivery Date", Visibility = PXUIVisibility.SelectorVisible)]
public DateTime? UsrDeliveryDate
{
get;
set;
}
#endregion
然后我使用下面的代码使用网络服务更新此交货日期 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 的交易。
通过将 LinkedCommand 设置为 null
和 Commit[ 来修改 Type 字段的原因是什么? =23=] 到 false?
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/Whosebug/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();
}
我在 header 屏幕发票和备忘录中创建了新的附加字段,请参考下面的屏幕截图。
下面这个是DAC:
#region UsrDeliveryDate
public abstract class usrDeliveryDate : IBqlField{}
[PXDBDate()]
[PXUIField(DisplayName="Delivery Date", Visibility = PXUIVisibility.SelectorVisible)]
public DateTime? UsrDeliveryDate
{
get;
set;
}
#endregion
然后我使用下面的代码使用网络服务更新此交货日期 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 的交易。
通过将 LinkedCommand 设置为 null
和 Commit[ 来修改 Type 字段的原因是什么? =23=] 到 false?
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/Whosebug/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();
}