Acumatica采购订单行添加库存属性定制报错求助
问题排查与解决方法
错误1:Invalid column name [POLine].[UsrAttribute1]
排查与解决步骤
- 检查DAC扩展字段定义:确保自定义字段带有
[PXDB*]系列属性(如[PXDBString]),这是DAC字段映射到数据库列的核心配置。如果仅添加[PXUIField]而无数据库属性,系统会将其视为内存字段,不会在数据库中创建对应列,导致查询时找不到字段。 - 确认字段已同步到数据库:发布Acumatica自定义项目后,直接检查数据库
POLine表是否存在对应小写列(如usrattribute1,对应DAC中的UsrAttribute1)。若不存在,重新发布项目并查看发布日志是否有报错。 - 避免字段名冲突:建议使用语义化自定义字段名(如
UsrMatchCode而非UsrAttribute1),降低与系统预留字段冲突的概率。
错误2:使用rowExt.usrAttribute1赋值时编译报错
排查与解决步骤
- 区分实例属性与BQL抽象类:DAC扩展中,
UsrAttribute1是用于读写数据的实例属性(PascalCase命名),而usrAttribute1是仅用于BQL查询的抽象字段类(camelCase命名)。赋值操作必须使用实例属性,不能直接引用抽象类。 - 确保正确获取DAC扩展实例:必须通过
row.GetExtension<POLineExt>()方法获取扩展实例,而非手动实例化,否则属性无法正确绑定到Acumatica缓存系统。
完整代码示例
POLine DAC扩展
using PX.Data; namespace PX.Objects.PO { public class POLineExt : PXCacheExtension<POLine> { #region UsrMatchCode [PXDBString(100)] [PXUIField(DisplayName = "Match Code")] public virtual string UsrMatchCode { get; set; } public abstract class usrMatchCode : PX.Data.BQL.BqlString.Field<usrMatchCode> { } #endregion } }
POOrderEntry 图扩展
using PX.Data; using PX.Objects.IN; namespace PX.Objects.PO { public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry> { protected void _(Events.FieldUpdated<POLine, POLine.inventoryID> e) { if (e.Row == null) return; POLineExt rowExt = e.Row.GetExtension<POLineExt>(); InventoryItem item = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>> .Select(Base, e.Row.InventoryID); rowExt.UsrMatchCode = item?.MatchCode; } } }
内容的提问来源于stack exchange,提问作者Johann Mauersberger
相关产品推荐
相关产品推荐

