将供应商查找添加到自定义字段

Adding Vendor lookup to custom field

我在 SO 行上为 vendorid 添加了一个自定义字段。 (是的,我知道那里有一个,但我们正在构建一些新的逻辑)。我已经添加了整数字段,它很好地显示在网格上。我正在尝试查找供应商。我从这个开始

Where<AP.Vendor.type, NotEqual<BAccountType.employeeType>>>))]

然后尝试了

    Where<BAccountR.type, Equal<BAccountType.companyType>, 
        Or<AP.Vendor.type, NotEqual<BAccountType.employeeType>>>>), 
    Visibility = PXUIVisibility.SelectorVisible, CacheGlobal = true, Filterable = true)]

它让我查找了新记录,但是当我保存并尝试打开任何销售订单时,我收到一条错误消息 "Error: An error occurred during the processing of the field InventoryID: Specified cast is not valid..",这使得对我来说没有意义。但是,如果我删除上面的内容,它就会起作用,所以看起来一定是问题所在。

请求的堆栈跟踪: 错误:错误:处理字段 InventoryID 时发生错误:指定的转换无效..

    Raised At: 2/24/2020 6:47:58 PM     Screen: SO.30.10.00         

Details:
2/24/2020 6:47:58 PM Error:
Error: An error occurred during processing of the field InventoryID: Specified cast is not valid..

System.InvalidCastException: Specified cast is not valid.
   at System.Data.SqlClient.SqlBuffer.get_Int32()
   at PX.Data.PXDataRecord.GetInt32(Int32 i)
   at PX.Data.PXDBIntAttribute.RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
   at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly)
   at PX.Data.PXCache.OnRowSelecting(Object item, PXDataRecord record, Int32& position, Boolean isReadOnly)
   at PX.Data.PXCache`1.Select(PXDataRecord record, Int32& position, Boolean isReadOnly, Boolean& wasUpdated)
   at PX.Data.PXView.GetResult(Object[] parameters, PXFilterRow[] filters, Boolean reverseOrder, Int32 topCount, PXSearchColumn[] sorts, Boolean& overrideSort, Boolean& extFilter)
   at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
   at PX.Objects.SO.SOOrderEntry.transactions()
   at _CustomMethod(Object , Object[] )
   at PX.Data.PXView.InvokeDelegate(Object[] parameters)
   at PX.Data.PXView.Select(Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows)
   at PX.Data.PXGraph.ExecuteSelect(String viewName, Object[] currents, Object[] parameters, Object[] searches, String[] sortcolumns, Boolean[] descendings, PXFilterRow[] filters, Int32& startRow, Int32 maximumRows, Int32& totalRows) 

有人有什么想法吗?

评论太长,但比 "answer" 更像是建议。尝试构建您自己的 PXSelector。我有一个需要存储两个供应商的自定义 DAC,我不得不放弃自定义 PXSelector 的 AP.Vendor 属性,以便我的工作。这是我的一个。在我的例子中,我需要能够看到哪个被定义为仓库的首选供应商,我只想看到与我的 InventoryID 关联的供应商。 SSINItemBranch 是一个自定义 DAC,也可在此 DAC 的使用范围内使用。关键是,如果您需要尝试从头开始创建自己的,请以此为例。如果这不是您想要完成任务的方式,至少您可以确定问题是 AP.Vendor 属性的用例还是其他问题。

[PXSelector(
        typeof(Search2<
            Vendor.bAccountID,
            InnerJoin<POVendorInventory,
                On<POVendorInventory.vendorID, Equal<Vendor.bAccountID>,
                And<POVendorInventory.inventoryID, Equal<Current<SSINItemBranch.inventoryID>>>>,
            LeftJoin<INItemSite, On<INItemSite.inventoryID, Equal<POVendorInventory.inventoryID>,
                And<INItemSite.preferredVendorID, Equal<POVendorInventory.vendorID>,
                And<INItemSite.preferredVendorLocationID, Equal<POVendorInventory.vendorLocationID>,
                And<INItemSite.preferredVendorOverride, Equal<True>>>>>>>,
                Where<Vendor.type, Equal<BAccountType.vendorType>>>),
        typeof(Vendor.acctCD),
        typeof(Vendor.acctName),
        typeof(POVendorInventory.vendorLocationID),
        typeof(INItemSite.preferredVendorOverride),
        typeof(POVendorInventory.vendorInventoryID),
        typeof(POVendorInventory.vLeadTime),
        SubstituteKey = typeof(Vendor.acctCD),
        DescriptionField = typeof(Vendor.acctName),
        Filterable = true
        )]

TL;DR;

从字段中删除 PXDBInt 属性。


这里的问题不在于 Where 条件,而在于字段的属性定义。

 [PXDBInt]  
 [PXUIField(DisplayName="Vendor ID")] 
 [AP.Vendor(typeof(Search<BAccountR.bAccountID, Where<AP.Vendor.type,
 NotEqual<BAccountType.employeeType>>>))]

实际上,这里有两次 DBField 属性。您有 PXDBIntAttributeVendor 属性,其中包含 PXDBIntAttribute

因为框架有错误的字段到 db 列映射导致那个奇怪的错误。

如果您使用 Visual studio,我建议您尝试 Acuminator 扩展 https://marketplace.visualstudio.com/items?itemName=Acumatica.Acuminator

它突出了那种类型的错误