我在屏幕发票和备忘录的标题中创建了新的附加字段,请参阅下面的屏幕截图。
以下是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的交易不起作用。
答案 0 :(得分:0)
通过将 LinkedCommand 设置为null
并将提交设置为 来修改类型字段的原因是什么假 强>
kon.InvoiceSummary.Type.LinkedCommand = null;
kon.InvoiceSummary.Type.Commit = false;
下面的示例工作正常,无需修改类型字段:
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();
}