如何将通配符附加到DAC字段的子字符串?

时间:2019-06-19 17:41:39

标签: acumatica

我正在定制的屏幕是“请求”屏幕(RQ301000)-我想修改网格中的Vendor查找以基于标题中选择的Request类。我已经知道如何修改“供应商”选择器以包括过滤器,就像我在“申请单”屏幕上所做的那样-但这种自定义包括为“请求类别”添加用户字段(“申请单”屏幕上不存在)。

我确实有以前获得的代码,该代码获得了字段的通配符附加值。问题是,此代码使用的用户字段与通配符字段位于同一DAC中-代码如下所示:

public class RQRequisitionExt : PXCacheExtension<RQRequisition>
{
    #region UsrRequestClass
    [PXDBString(10, IsUnicode = true)]
    [PXUIField(DisplayName = "NSA Request Class", Visibility = PXUIVisibility.SelectorVisible)]
    [PXSelector(typeof(RQRequestClass.reqClassID), DescriptionField = typeof(RQRequestClass.descr))]
    public virtual string UsrRequestClass { get; set; }
    public abstract class usrRequestClass : IBqlField {}
    #endregion


    //This is a DAC field that creates / tacks on a wildcard to the end of the UsrRequestClass field above...
    public abstract class myFieldWildcard : IBqlField { };
    [PXString(30, IsUnicode = true)]
    public virtual string MyFieldWildcard
    {
        [PXDependsOnFields(typeof(usrRequestClass))]
        get
        {
            //return PXDatabase.Provider.SqlDialect.WildcardAnything + UsrRequestClass + PXDatabase.Provider.SqlDialect.WildcardAnything;
            if (UsrRequestClass != null)
                return PXDatabase.Provider.SqlDialect.WildcardAnything + UsrRequestClass.Substring(0, 2) + PXDatabase.Provider.SqlDialect.WildcardAnything;
            else
                return UsrRequestClass;
        }
    }


}

对于我要在“请求”屏幕上执行的操作,我没有为此使用用户字段-我已经在屏幕上使用了“请求类别”字段-但我不知道如何获取该值该字段的字段可在通配符“ get”例程中使用。

本质上,我想在屏幕上获取“请求类”值,并在此通配符字段中使用它来返回到修改后的“供应商”选择器(未显示-但使用CacheAttached事件完成)。

任何帮助将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:0)

对我来说,解决方案是在包含通配符字段的同一DAC扩展中重新定义“请求类”字段,如下所示:

public class RQRequestExt : PXCacheExtension<RQRequest>
{

    //Redefine the Request Class in this DAC extension
    #region ReqClassID
    public abstract class reqClassID : IBqlField {}
    [PXDBString(10, IsUnicode = true)]
    [PXDefault(typeof(RQSetup.defaultReqClassID))]
    [PXUIField(DisplayName = "Request Class", Visibility = PXUIVisibility.SelectorVisible)]
    [PXSelector(typeof(RQRequestClass.reqClassID), DescriptionField = typeof(RQRequestClass.descr))]
    public virtual string ReqClassID { get; set; }
    #endregion

    //This is a DAC field that creates / tacks on a wildcard to the end of the UsrRequestClass field above...
    public abstract class rQRequestwildcard : IBqlField { };
    [PXString(30, IsUnicode = true)]
    public virtual string RQRequestwildcard
    {
        [PXDependsOnFields(typeof(RQRequest.reqClassID))]
        get
        {
            if (ReqClassID != null)
                return PXDatabase.Provider.SqlDialect.WildcardAnything + ReqClassID.Substring(0, 2) + PXDatabase.Provider.SqlDialect.WildcardAnything;
            else
                return PXDatabase.Provider.SqlDialect.WildcardAnything;
        }
    }
}

这样,我可以引用通配符字段操作中使用的“请求类ID” ...