控制具有相同字段值的记录AX 2012

问题描述 投票:0回答:1

我有一个名为 PaymentLines 的表,我想控制具有相同 InvoiceId 值的记录的 dueDate 字段,如果有不同的 dueDate 值,info -> 具有相同 InvoiceId 值的记录不能有不同的 dueDate 值。如果有不同的 dueDate 值,info -> 具有相同 InvoiceId 值的记录不能有不同的 dueDate 值。

我怎样才能做到这一点?

enter image description here

axapta x++ dynamics-ax-2012-r3
1个回答
1
投票

这取决于你什么时候想控制,例如,如果你想做控制时,你把值在 DueDate 字段覆盖 Modified 数据源中该字段的事件 PaymentLines.

PaymentLines PaymentLinesCheck;

;

select PaymentLinesCheck where PaymentLinesCheck.InvoiceId == PaymentLines.InvoiceId &&
                               PaymentLinesCheck.DueDate != PaymentLines.DueDate;
if(PaymentLinesCheck)
{
    info("Records with the same InvoiceId value cannot have different dueDate values");
    //If you want to show an error message
    //error("Records with the same InvoiceId value cannot have different dueDate values");
    PaymentLines.DueDate = DateNull();        
}
© www.soinside.com 2019 - 2024. All rights reserved.