0
votes

I am trying to add an Employees selector to the Journal Transactions screen (GL301000) specifically in the grid. I have created the DAC extension code using the GLTran DAC as the base. Here is my code:

using PX.Common;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.TX;
using PX.Objects;
using System.Collections.Generic;
using System;

namespace PX.Objects.GL
{
  public class GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
  {
    #region Resource
  public class emp: PX.Data.Constant<string>
{
    public emp() : base("EMPHOUR") { }
}
    public abstract class resource: PX.Data.IBqlField
    {
    }
    protected int? _Resource;

    [PXDBInt]
    [PXDefault()]
    [PXUIField(DisplayName="Resource")]
    [PXSelector(typeof(Search2<BAccount.bAccountID,
    InnerJoin<Vendor,
    On<Vendor.bAccountID,
    Equal<BAccount.bAccountID>>>,
    Where<Vendor.vendorClassID,
    Equal<emp>>>),
    SubstituteKey = typeof(BAccount.acctName))]
        public virtual int? Resource
    {
      get
      {
        return this._Resource;
      }
      set
      {
        this._Resource = value;
      }
    }
    #endregion
  }
}

I am getting an error when I try to add the field to the grid and this is my error:

Error: An invalid selector column has been provided.
Parameter name: fieldList

Can anyone point me in the right direction? I do know that to get the correct Employee's names to show up you must use a where or join on the Vendor table and the BAccount tables. When I tried the LeftJoin method however, I got an error saying multi-part identifier could not be bound.

1
to store the business account you should use an int field and use the vendor attribute/selector. I don't see this field as a DB field so the values are not going to save. are you trying to save the values with the results? - Brendan
Yes I am, I tried changing to PXDBInt and all string's to an int? with still the same error. - Dane
if you are keeping the same select you will as you are using 2 different DACs without a Join. Did you try using the VendorAttribute? then add a PXRestrictor with your where condition on top of that attribute for your PXDBInt field? - Brendan
First of all try to change the Search to Search2 and write the query with Join. - Samvel Petrosov
I have updated my code above with a Search2 and an Inner Join. I am still receiving the same error however. This error also comes up and covers the whole page so I cannot even reach the actual Journal Transactions page. - Dane

1 Answers

0
votes

I have found a solution.

I needed to add a persisting check to the PXDefault and also change the CommitChanges property to true.

Here is the correct code below:

public class GLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
  {
    #region Resource
  public class emp: PX.Data.Constant<string>
{
    public emp() : base("EMPHOUR") { }
}
    public abstract class resource: PX.Data.IBqlField
    {
    }
    protected int? _Resource;

    [PXDBInt]
    [PXDefault(PersistingCheck=PXPersistingCheck.Nothing)]
    [PXUIField(DisplayName="Resource")]
    [PXSelector(typeof(Search2<BAccount.bAccountID,
    InnerJoin<Vendor,
    On<Vendor.bAccountID,
    Equal<BAccount.bAccountID>>>,
    Where<Vendor.vendorClassID,
    Equal<emp>>>),
    SubstituteKey = typeof(BAccount.acctName))]
        public virtual int? Resource
    {
      get
      {
        return this._Resource;
      }
      set
      {
        this._Resource = value;
      }
    }
    #endregion
  }

Also remember to create a DB Script to add the Resource field to the GLTran table of the value INT.