Acumatica - 根据另一个字段的值创建所需字段

时间:2018-05-04 16:29:05

标签: acumatica

首先,我将说我正在使用Acumatica的6.1版服务管理模块。这意味着服务管理是一个项目,而不是此时的标准。我正在尝试根据另一个自定义Usr字段的值在Service Orders屏幕上的选项卡中创建一个自定义的Usr字段。我尝试了RowUpdatedFieldUpdated个事件。我已将下面的代码包括在内,并在两者上都有相应的错误。

现场更新:

protected void FSServiceOrder_Usrwarrstat_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
    {
      if(InvokeBaseHandler != null)
        InvokeBaseHandler(cache, e);
      var row = (FSServiceOrder)e.Row;
      if(row == null) return;
      var WarrantyStatus = row.Usrwarrstat;
      if (WarrantyStatus == null) return;
      if (WarrantyStatus == "W" || WarrantyStatus == "P"){
        PXDefaultAttribute.SetPersistingCheck<FSServiceOrderExt.usrTransModelNbr>(cache, e, PXPersistingCheck.NullOrBlank);
      }

    }

错误:

\App_RuntimeCode\ServiceOrderEntry.cs(484): error CS1061: 'FieldService.ServiceDispatch.FSServiceOrder' does not contain a definition for 'Usrwarrstat' and no extension method 'Usrwarrstat' accepting a first argument of type 'FieldService.ServiceDispatch.FSServiceOrder' could be found (are you missing a using directive or an assembly reference?)

行更新:

protected void FSServiceOrder_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
                {

                    var row = (FSServiceOrder)e.Row;
                    var WarrantyStatus = Base.Caches[typeof(FSServiceOrder)].Current.Usrwarrstat;
                    if(row == null) return;
                    if (WarrantyStatus == null) return;
                    if (WarrantyStatus == "W" || WarrantyStatus == "P"){
                    PXDefaultAttribute.SetPersistingCheck<FSServiceOrderExt.usrTransModelNbr>(cache, e, PXPersistingCheck.NullOrBlank);
                    }

                }

错误:

\App_RuntimeCode\ServiceOrderEntry.cs(377): error CS1061: 'object' does not contain a definition for 'Usrwarrstat' and no extension method 'Usrwarrstat' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

我觉得这与服务管理有关,此时在这个版本中不是Acumatica的标准,因此使cusotm字段不会将其绑定到正确的视图,但我可能是错的。

2 个答案:

答案 0 :(得分:3)

您可以使用this.chose_button.on('click', () => { tryInputSong(this, this.link_input.val()); }); 属性根据条件创建所需字段,而无需编写任何事件处理程序。您必须将此属性应用于PXUIRequired字段(在DAC级别):

usrTransModelNbr

请注意,您需要为您的&#34; W&#34;定义实际的BQL常量。和&#34; P&#34;值;我不知道他们的意思,只是给了他们一个假名。 BQL常量需要定义如下:

[PXUIRequired(typeof(Where<usrwarrstat, Equal<warrantyW>, Or<usrwarrstat, Equal<warrantyP>>>))]

BQL常量可以在任何地方定义,但我建议将它们与 public class warrantyW : Constant<string> { public warrantyW() : base("W") { } } 的自定义版本放在usrwarrstat中(定义在此下拉列表中可供选择的值)。这是PX.Objects的一个例子;在此示例中,您将使用PXStringListAttribute而不是[TaxAdjustmentType.List]

来装饰您的字段
[PXStringList(...)]

您可以在http://asiablog.acumatica.com/2016/11/pxuienabled-and-pxuirequired-attributes.html了解有关此属性和其他相关属性的更多信息,例如public class TaxAdjustmentType { public class ListAttribute : PXStringListAttribute { public ListAttribute() : base( new string[] { AdjustOutput, AdjustInput }, new string[] { Messages.AdjustOutput, Messages.AdjustInput }) { } } public const string AdjustOutput = "INT"; public const string AdjustInput = "RET"; public const string InputVAT = "VTI"; public const string OutputVAT = "VTO"; public const string ReverseInputVAT = "REI"; public const string ReverseOutputVAT = "REO"; public class adjustOutput : Constant<string> { public adjustOutput() : base(AdjustOutput) { ;} } public class adjustInput : Constant<string> { public adjustInput() : base(AdjustInput) { ;} } public class inputVAT : Constant<string> { public inputVAT() : base(InputVAT) { ;} } public class outputVAT : Constant<string> { public outputVAT() : base(OutputVAT) { ;} } public class reverseInputVAT : Constant<string> { public reverseInputVAT() : base(ReverseInputVAT) { ;} } public class reverseOutputVAT : Constant<string> { public reverseOutputVAT() : base(ReverseOutputVAT) { ;} } } PXUIEnabled

答案 1 :(得分:1)

您收到此错误是因为您尝试从DAC访问自定义字段,而不是从CacheExtension访问该字段。我建议你在RowSelected事件处理程序中执行此操作,如下所示:

protected void FSServiceOrder_RowSelected(PXCache sender, PXRowUpdatedEventArgs e,PXRowSelected baseMethod)
{
    if(baseMethod!=null)       //
        baseMethod(sender,e);  // this is equal to this line    baseMethod?.Invoke(sender,e);
    if(e.Row == null) return;
    FSServiceOrder row = (FSServiceOrder)e.Row;

    FSServiceOrderExt rowExt = PXCache<FSServiceOrder>.GetExtension<FSServiceOrderExt>(row);
    if(rowExt!=null)
    {
        if (rowExt.Usrwarrstat == null) 
            return;
        if (rowExt.Usrwarrstat == "W" || rowExt.Usrwarrstat == "P"){
            PXDefaultAttribute.SetPersistingCheck<FSServiceOrderExt.usrTransModelNbr>(cache, e, PXPersistingCheck.NullOrBlank);
        }
    }
}