2017-10-06 11 views
0

ベンダーが選択されている場合、すべてのレコードを検索するカスタムパーツセレクタを作成しようとしています。セレクタの結果をフィルタリングして、ベンダーを選択します。AcumaticaカスタムセレクタSQLエラー - 不適切な構文

使用PXCustomSelectorAttribute:

SQLエラー:キーワードの近くに不正な構文 'AND' キーワード、私は別の例外を見つけることができた '注文'

 [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; 
      } 

     } 

    } 
} 

enter image description here

+0

スタックトレースによると、SOOrderEntry拡張クラスの1693行目に例外がスローされます。 SQLプロファイラを使用してSQLクエリをキャプチャして、このエラーの原因となるものを前提にする前に、このエラーを引き起こすことをお勧めします。 – RuslanDev

+0

ありがとうRuslan、GetRecords()は、PXCustomSelectorAttributeクラスと正しく整列しますか? SOLine Extensionからカスタムセレクターにコメントすると、このエラーは表示されなくなります – nickivey

答えて

0

近く 不適切な構文ビジュアルスタジオでのデバッグ中に 私の問題はSOLine Extensionを参照するときにフィールドをBAccountとしてキャストしようとしたためです。キャストを変更して問題を解決しました

関連する問題