如何检查 Acumatica 事件处理程序中的状态 (Active/Inactive)?

How Can I Check The Status (Active/Inactive) In Acumatica Event Handler?

谁能告诉我如何检查 Acumatica 中的客户状态是活跃还是不活跃。我正在使用以下代码,但无法弄清楚真正的价值应该是什么:

if (row != null){
        if (row.Status == <status.Active>){
          //DO SOMETHING
        }
        else{
          //DO SOMETHING ELSE
        }
      }

如果我想检查客户状态是否有效,我可以用什么来代替?

谢谢, G

我想如果你有类似的东西:

if (row.status == Customer.status.Active)

应该可以。您将需要 using/reference 用于 AR 对象。

您可以通过在设计模式下打开客户表单来查看状态字段上的属性。通过这样做,您可以看到它实际上是 DAC 中的哪个字段以及该字段的下拉列表中可用的内容。以下是状态字段的属性。

new string[] { Active, Hold, CreditHold, Inactive, OneTime },
new string[] { CR.Messages.Active, CR.Messages.Hold,CR.Messages.CreditHold, CR.Messages.Inactive, CR.Messages.OneTime }) { }
}}
[PXDBString(1, IsFixed = true)]
[PXDefault(status.Active)]
[PXUIField(DisplayName = "Status")]
[status.List()]

// below are the values for the CR.Messages if you care to see

public const string Active = "Active";
public const string Hold = "On Hold";
public const string HoldPayments = "Hold Payments";
public const string Inactive = "Inactive";
public const string OneTime = "One-Time";
public const string CreditHold = "Credit Hold";

进一步查看源代码可知,客户状态字段实际上是BAccounttable中的一个名为Status的字段。它是一个单字符字段,Active = 'A'、Inactive = 'I' 的值。 (还有更多的值)

因此,如果您只是想知道客户是否活跃,类似于 Max 发布的内容,您只需在事件处理程序之一中执行此操作,其中当前行定义为 row:

if (row.status == 'A')  // if customer status is Active...
{
//do something
}

可能有一个常数可以使用,这会更好。