我正在尝试显示使用PXFormula计算的值,但该字段未显示该值。我的CustomDAC名为EDITran
public class EDITran : IBqlTable
{
#region Doctype
[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Doctype")]
[PXStringList
(new string[]
{"SO", "SHI", "INV" },
new string[]
{"Sales Order", "Shipment", "Invoice"}
)]
public virtual string Doctype { get; set; }
public abstract class doctype : PX.Data.BQL.BqlString.Field<doctype> { }
#endregion
#region Erprefnbr
[PXDBString(30, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "ERP RefNbr")]
public virtual string Erprefnbr { get; set; }
public abstract class erprefnbr : PX.Data.BQL.BqlString.Field<erprefnbr> { }
#endregion
#region Sync
[PXDBBool()]
[PXUIField(DisplayName = "Sync")]
public virtual bool? Sync { get; set; }
public abstract class sync : PX.Data.BQL.BqlBool.Field<sync> { }
#endregion
}
}
所以我要在“销售订单”屏幕上显示同步值的字段。关键是ERP RefNbr(将为SOOrder.OrderNbr)
我已使用此属性在SOOrderExt DAC上添加了自定义非持久字段
using PX.Objects.SO;
[PXBool]
[PXUIField(DisplayName="EDI Sync" , Enabled = false)]
[PXFormula(typeof(Selector<SOOrder.orderNbr,
Selector<EDITran.erprefnbr,
EDITran.sync>>))]
但是当我在EDITran中添加一条记录并尝试在SOOrder Form中对其进行可视化并且我检查EDITran.Sync = 1时,它没有显示已保存的值。
我做错了什么?是否正确使用了PXFormula?
我不确定PXFormula是否正确使用。这是我需要使用PXFormula时通常使用的参考。看看它是否可以帮助您简化PXFormula。您可能需要简化为单个选择器并定义一个外键才能完成查找。
而且,您确定数据库包含所需的值吗?我经常发现我的问题不在我想的地方,而您的问题可能在于设置值或将其写入业务逻辑中的数据库。
[您似乎需要PXFormula来查看EDITran表,以找到由键(在Selector中指定的第一个字段)标识的记录,然后返回指定的第二个字段的值,该值位于EDITran中。
来自Acumatica Developers Blog (AsiaBlog):
选择器
选择器执行以下操作:
获取在当前DAC的外键字段(KeyField)上定义的PXSelectorAttribute。获取选择器当前引用的外部数据记录。使用计算并返回由ForeignOperand定义的该数据记录上的表达式。
public class APVendorPrice : IBqlTable
{
// Inventory attribute is an aggregate containing a PXSelectorAttribute
// inside, which is also valid for Selector<>.
[Inventory(DisplayName = "Inventory ID")]
public virtual int? InventoryID
[PXFormula(typeof(Selector<
APVendorPrice.inventoryID,
InventoryItem.purchaseUnit>))]
public virtual string UOM { get; set; }
}
因此,我希望您的PXFormula看起来更像:
[PXFormula(typeof(Selector<
SOOrder.orderNbr,
EDITran.sync>))]
...假设您已经定义了足够的内容,可以告诉Acumatica如何将SOOrder.orderNbr与EDITran.erprefnbr相关联。
PXFormula
使用不正确。 PXFormula
属性仅适用于以SOOrder
PXSelector
条件存在的当前DAC(为join
)或外部DAC(可以使用Selector
关键字来获取)。例如,这是SOOrder.OrderNbr
选择器声明
[SO.RefNbr(typeof(Search2<SOOrder.orderNbr,
LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>,
And<Where<Match<Customer, Current<AccessInfo.userName>>>>>>,
Where<SOOrder.orderType, Equal<Optional<SOOrder.orderType>>,
And<Where<Customer.bAccountID, IsNotNull,
Or<Exists<Select<SOOrderType,
Where<SOOrderType.orderType, Equal<SOOrder.orderType>,
And<SOOrderType.aRDocType, Equal<ARDocType.noUpdate>,
And<SOOrderType.behavior, Equal<SOBehavior.sO>>>>>>>>>>,
OrderBy<Desc<SOOrder.orderNbr>>>), Filterable = true)]
public virtual String OrderNbr
您可以使用Customer
关键字从相关的Selector
记录中获取一些字段
[PXFormula(typeof(Selector<
SOOrder.orderNbr,
Customer.consolidateStatements>))]
因此,有两种可能的解决方案:
[1)用您的SOOrder.OrderNbr
DAC重写EDITran
选择器声明>
... [SO.RefNbr(typeof(Search2<SOOrder.orderNbr, LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>, And<Where<Match<Customer, Current<AccessInfo.userName>>>>>, LeftJoin<EDITran, On<EDITran.doctype, Equal<SOOrder.orderType>, And<EDITran.erprefnbr, Equal<SOOrder.orderNbr>>>>>, Where<SOOrder.orderType, Equal<Optional<SOOrder.orderType>>, And<Where<Customer.bAccountID, IsNotNull, Or<Exists<Select<SOOrderType, Where<SOOrderType.orderType, Equal<SOOrder.orderType>, And<SOOrderType.aRDocType, Equal<ARDocType.noUpdate>, And<SOOrderType.behavior, Equal<SOBehavior.sO>>>>>>>>>>, OrderBy<Desc<SOOrder.orderNbr>>>), Filterable = true)] public virtual String OrderNbr
那么就有可能从那里得到你的领域
使用[PXFormula(typeof(Selector< SOOrder.orderNbr, EDITran.sync>))]
2)
PXDBScalar
属性即可获取所需的内容。请注意,这将是对数据库的单独请求!...
[PXBool]
[PXDBScalar(typeof(Search<EDITran.sync,
Where<EDITran.doctype, Equal<SOOrder.orderType>,
And<EDITran.erprefnbr, Equal<SOOrder.orderNbr>>>>))]
public virtual bool? Sync