acumatica - 全局通用字段更新事件
问题描述
我有 50 多个自定义配对字段“英寸”和“厘米”,每个字段都已启用且可编辑。如果用户更改了“厘米”和签证的值,我需要更新“英寸”。在字段更新事件期间,我能够在其中一个配对字段上使用 SetValuePending 并在另一个字段上使用 SetValueExt 来做到这一点。我的问题是,有没有一种方法可以在更高级别上执行此操作,而无需为所有 100 多个字段执行 Field_Updated 事件。我知道公式会创建循环引用,因此无法使用。谢谢
解决方案
您可以通过PXFormula
+ ExternalValue
BQL 表达式(与PXRowUpdatedEventArgs.ExternalCall
示例相同)来执行此操作,这将防止对字段之间的循环引用。想法是仅当用户从 UI 更改相关字段时才计算字段(ExternalCall
= true),并在公式更新相关字段时跳过计算(ExternalCall
= false)。
public class centimetersInInches : PX.Data.BQL.BqlDecimal.Constant<centimetersInInches>
{
public centimetersInInches() : base(2.54m) { }
}
[PXDecimal]
[PXUIField(DisplayName = "Inches")]
[PXUnboundDefault(TypeCode.Decimal, "0.0")]
[PXFormula(typeof(ExternalValue<Div<centimeters, centimetersInInches>>))]
public virtual decimal? Inches { get; set; }
public abstract class inches : PX.Data.BQL.BqlDecimal.Field<inches> { }
[PXDecimal]
[PXUIField(DisplayName = "Centimeters")]
[PXUnboundDefault(TypeCode.Decimal, "0.0")]
[PXFormula(typeof(ExternalValue<Mult<inches, centimetersInInches>>))]
public virtual decimal? Centimeters { get; set; }
public abstract class centimeters : PX.Data.BQL.BqlDecimal.Field<centimeters> { }
和aspx
<px:PXGridColumn DataField="Inches" CommitChanges="True" />
<px:PXGridColumn DataField="Centimeters" CommitChanges="True" />
推荐阅读
- java - 您如何将 BigInteger 与 for 循环和修改 BigIntegers 一起使用?
- c# - 带有标题和内容的 HttpClient PostAsync c#
- c# - 使用 Texture2D 创建平滑圆角矩形
- java - ArrayList - 索引与大小
- django - AWS 弹性 beantalk 上的 Django 项目始终具有“严重”的健康状况和 100% 的 CPU 负载
- javascript - 为什么会触发两个事件侦听器而不是一个?
- regex - sas 子字符串到第一个空格
- r - 将数值变量转换为 dplyr 中的因子
- php - 如何强制浏览器等到 php 服务器发送响应?
- javascript - socket.io 加入房间 N 次时发送 N 条消息