【问题标题】:Acumatica Custom Selector SQL Error - Incorrect Syntax near the keywordAcumatica 自定义选择器 SQL 错误 - 关键字附近的语法不正确
【发布时间】:2017-10-06 23:28:39
【问题描述】:

如果没有选择供应商,我正在尝试创建自定义部件选择器来搜索所有记录,如果选择了供应商,我想过滤选择器的结果以仅包含选择供应商的部件。

使用 PXCustomSelectorAttribute:

SQL 错误:关键字“AND”附近的语法不正确 关键字“ORDER”附近的语法不正确

       [PXNonInstantiatedExtension]
public class SO_SOLine_ExistingColumn : PXCacheExtension<PX.Objects.SO.SOLine>
{
    #region InventoryID  

    [PXMergeAttributes(Method = MergeMethod.Replace)] //was append
    [PXUIField(DisplayName = "Part #")]
    [PartSelector(typeof(SOLineExt.usrCusVendor))]
    public int? InventoryID { get; set; }

    #endregion
}

public class PartSelector : PXCustomSelectorAttribute
{

    [Serializable]
    [PXProjection(typeof(
         Select2<atcVendorItem,
             LeftJoin<InventoryItem,
                   On<InventoryItem.inventoryCD, Equal<atcVendorItem.inventoryCD>, And<InventoryItem.inventoryID, Equal<atcVendorItem.inventoryID>>>>>), Persistent = false)]
    public class atcPartView : IBqlTable
    {
        // DAC W/Inventory Item Table mapped and joined with Vendor Items
    }


    //Selected table
    private Type _MfgField;


    ////way to have multiple description fields 
    public PartSelector(Type MfgField) : base(typeof(atcPartView.inventoryID))
    {
        _MfgField = MfgField;

    }

    protected virtual IEnumerable GetRecords()
    {
        var cache = this._Graph.Caches[BqlCommand.GetItemType(_MfgField)];
        var cbs = (BAccount)cache.Current;

        // make mfgfield 
        if (cbs != null)
        {
            foreach (atcPartView p in PXSelect<atcPartView, Where<atcPartView.vendorID, Equal<Required<SOLineExt.usrMfg>>>>.Select(_Graph, cbs.BAccountID))
            {
                yield return p;
            }

        }
        else
        {
            foreach (atcPartView p in PXSelect<atcPartView, Where<atcPartView.vendorID, IsNotNull>>.Select(_Graph))
            {
                yield return p;
            }

        }

    }
}

【问题讨论】:

  • 根据堆栈跟踪,在您的 SOOrderEntry 扩展类的第 1693 行引发了异常。我建议使用 SQL Profiler 捕获导致此错误的 SQL 查询,然后再对究竟是什么导致此问题做出任何假设。
  • 感谢 Ruslan,GetRecords() 是否与 PXCustomSelectorAttribute 类正确对齐?如果我将自定义选择器从 SOLine 扩展中注释掉,这个错误就会消失

标签: acumatica


【解决方案1】:

我在 Visual Studio 中调试时发现了另一个异常, 我的问题是因为我在引用 SOLine 扩展时试图将该字段转换为 BAccount。更改演员表解决了我的问题

【讨论】:

    猜你喜欢
    • 2011-04-07
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 2018-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多