有没有一种方法可以使用户定义的字段进入选择器? [英] Is there a way to get User Defined Fields into selectors?

查看:83
本文介绍了有没有一种方法可以使用户定义的字段进入选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个利用用户定义的"字段的客户.我发现这些值位于数据库的KvExt表中,但是我没有找到直接通过DAC或DAC扩展访问这些值的方法.有什么方法可以访问该字段并将其添加到基本的Acumatica页面?

I have a customer utilizing the User Defined fields. I found that the values are located in KvExt tables in the database, but I have not found a way to access those directly through DACs or DAC extensions. Is there a way I can access that field and add it to a base Acumatica page?

我的具体目标是ARPayments页面中的ARTran.RefNbr选择器.

The specific target in my case is the ARTran.RefNbr selector in the ARPayments page.

推荐答案

您可能已经知道用户定义字段实际上是在使用系统中定义的属性.用户定义字段和实际记录(例如ARInvoice)受记录(ARInvoice)的NoteID和用户定义字段的RecordID约束.用户定义字段的FieldName存储单词'Attribute'+ AttributeID.

As you probably know the User Defined Fields are actually using the Attributes defined in the system. The User Defined Field and actual record (for example ARInvoice) are bound by NoteID of the record (ARInvoice) and RecordID of the User Defined Field. And the FieldName of the User Defined Field is storing word 'Attribute' + AttributeID.

下面的SQL查询显示引用:

Below SQL Queries show that references:

SELECT CompanyID, RefNbr, DocType, DocDesc FROM ARRegister WHERE RefNbr='AR007092';

SELECT CompanyID, RecordID, FieldName, ValueNumeric, ValueDate, ValueString, ValueText FROM ARRegisterKvExt where RecordID='78A9D6DE-52C4-E911-B2FD-FC017C8C8936';

SELECT CompanyID, AttributeID, Description, ControlType, EntryMask, RegExp, List, IsInternal, ContainsPersonalData FROM CSAttribute WHERE'AttributeBURDEN' LIKE  '%'+AttributeID;

结果集:

了解了上面显示的参考之后,我们可以为ARRegisterKvExt表创建一个DAC,如下所示:

After knowing the references shown above, we can create a DAC to the ARRegisterKvExt table like below:

[PXCacheName("AR Register Attributes")]
[Serializable]
public class ARRegisterKvExt : IBqlTable
{
    public abstract class recordID : BqlGuid.Field<recordID> { }
    [PXDBGuid(IsKey = true)]
    public Guid? RecordID { get; set; }

    public abstract class fieldName : BqlString.Field<fieldName> { }
    [PXDBString(50,IsKey = true)]
    [PXUIField(DisplayName ="Name")]
    public string FieldName { get; set; }

    public abstract class valueNumeric : BqlDecimal.Field<valueNumeric> { }
    [PXDBDecimal(8)]
    [PXUIField(DisplayName = "Value Numeric")]
    public decimal? ValueNumeric { get; set; }

    public abstract class valueDate : BqlDateTime.Field<valueDate> { }
    [PXDBDate]
    [PXUIField(DisplayName = "Value Date")]
    public DateTime? ValueDate { get; set; }

    public abstract class valueString : BqlString.Field<valueString> { }
    [PXDBString(256)]
    [PXUIField(DisplayName = "Value String")]
    public string ValueString { get; set; }

    public abstract class valueText : BqlString.Field<valueText> { }
    [PXDBString]
    [PXUIField(DisplayName = "Value Text")]
    public string ValueText { get; set; }
}

并使用左连接将PXSelector写入我们的DAC和CSAttribute,如下所示:

And write a PXSelector with Left Joins to our DAC and CSAttribute like below:

[PXSelector(typeof(Search2<ARInvoice.refNbr, LeftJoin<ARRegisterKvExt, On<ARInvoice.noteID,Equal<ARRegisterKvExt.recordID>>, LeftJoin<CSAttribute, On<ARRegisterKvExt.fieldName,Contains<CSAttribute.attributeID>>>>>), new[] { typeof(ARInvoice.refNbr), typeof(ARInvoice.docType), typeof(CSAttribute.description), typeof(ARRegisterKvExt.valueString)}, DescriptionField = typeof(ARInvoice.docDesc))]

结果,您将看到如下查询:

As a result, you will see lookup like below:

您会看到没有用户定义字段值的AR发票也没有该字段的名称.这是由Acumatica处理用户定义字段的方式引起的.仅当您设置一个值时,用户定义字段的记录才被写入数据库.如果清除该值,则删除该记录.

As you can see the AR Invoices which don't have value for the User Defined Fields don't have the Name of the field too. This is caused by the way Acumatica is handling the User Defined Fields. The record for the User Defined Fields is being written to the database only when you set a value. And deletes that record if you clear the value.

在查找中使用用户定义的字段"的不利方面是,如果您有2个AR发票的用户定义的字段,则同一发票将显示两次,但前提是同时设置了两个用户定义的字段"的值.

The bad side of using the User Defined Fields in the lookups is that if you have 2 User Defined Fields for AR Invoice then the same Invoice will be shown twice, but only if the values for both User Defined Fields are set.

这篇关于有没有一种方法可以使用户定义的字段进入选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆