Solved

Error in connecting DAC extension (The type 'PX.Objects.GL.BatchExt' cannot be used as type parameter 'TTable' in the generic type or method)

  • 31 October 2022
  • 4 replies
  • 177 views

I have added a new “Check/Giro Number” field in Journal Transaction through this following code.

namespace PX.Objects.GL
{
    public class BatchExt : PXCacheExtension<PX.Objects.GL.Batch>
    {
        #region UsrCheckGiroNbr
        [PXString(11)]
        [PXUIField(DisplayName="Check/Giro Number")]

        public virtual string UsrCheckGiroNbr { get; set; }
        public abstract class usrCheckGiroNbr : PX.Data.BQL.BqlString.Field<usrCheckGiroNbr> { }
        #endregion

    }

}

I want to show this field in ARPayment so I add an DAC extension

#region UsrCheckGiroNumber
protected virtual void _(Events.RowSelecting<ARPayment> e)
{
   ARPayment row = (ARPayment)e.Row;
   if (row == null)
   {
        return;
   }
   using (new PXConnectionScope())
   {
     ARRegisterExt rowExt = row.GetExtension<ARRegisterExt>();
     usrCheckGiroNbr item = SelectFrom<BatchExt>
         .Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>
         .View.Select(Base, row.usrCheckGiroNbr);
     BatchExt itemExt = item.GetExtension<BatchExt>();
     rowExt.usrCheckGiroNumber = itemExt.usrCheckGiroNumber;
   }
}
#endregion

But there’s still an error during validation that shows 

error CS0311: The type 'PX.Objects.GL.BatchExt' cannot be used as type parameter 'TTable' in the generic type or method 'SelectFrom<TTable>'.

Any ideas about this issue?

icon

Best answer by Naveen Boga 1 November 2022, 06:26

View original

4 replies

Userlevel 5
Badge +1

BatchExt is a DAC Extension of Batch. You will want to update your SelectFrom:
SelectFrom<Batch>.Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>         .View.Select(Base, row.usrCheckGiroNbr);

Userlevel 7
Badge +17

@nurul74  The code should be like below.

 

#region UsrCheckGiroNumber
protected virtual void _(Events.RowSelecting<ARPayment> e)
{
   ARPayment row = (ARPayment)e.Row;
   if (row == null)
   {
        return;
   }
   using (new PXConnectionScope())
   {
     ARRegisterExt rowExt = row.GetExtension<ARRegisterExt>();'

     Batch item = SelectFrom<Batch>
         .Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>
         .View.Select(Base, row.usrCheckGiroNbr);


     BatchExt itemExt = item.GetExtension<BatchExt>();
     rowExt.usrCheckGiroNumber = itemExt.usrCheckGiroNumber;
   }
}
#endregion

BatchExt is a DAC Extension of Batch. You will want to update your SelectFrom:
SelectFrom<Batch>.Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>         .View.Select(Base, row.usrCheckGiroNbr);

@nurul74  The code should be like below.

 

#region UsrCheckGiroNumber
protected virtual void _(Events.RowSelecting<ARPayment> e)
{
   ARPayment row = (ARPayment)e.Row;
   if (row == null)
   {
        return;
   }
   using (new PXConnectionScope())
   {
     ARRegisterExt rowExt = row.GetExtension<ARRegisterExt>();'

     Batch item = SelectFrom<Batch>
         .Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>
         .View.Select(Base, row.usrCheckGiroNbr);


     BatchExt itemExt = item.GetExtension<BatchExt>();
     rowExt.usrCheckGiroNumber = itemExt.usrCheckGiroNumber;
   }
}
#endregion

@Shawn Burt @Naveen Boga 

It works for that error, but it causes more errors in the bellow code

error CS1061: 'ARRegisterExt' does not contain a definition for 'UsrCheckGiroNumber' and no accessible extension method 'UsrCheckGiroNumber' accepting a first argument of type 'ARRegisterExt' could be found (are you missing a using directive or an assembly reference?)

error CS1955: Non-invocable member 'BatchExt.UsrCheckGiroNbr' cannot be used like a method.
Userlevel 7
Badge +17

@nurul74  Two issues from the above code. Please find the updated code and verify.

 

#region UsrCheckGiroNumber
protected virtual void _(Events.RowSelecting<ARRegister> e)
{
   ARRegister row = (ARRegister)e.Row;
   if (row == null)
   {
        return;
   }
   using (new PXConnectionScope())
   {
     ARRegisterExt rowExt = row.GetExtension<ARRegisterExt>();'

     Batch item = SelectFrom<Batch>
         .Where<BatchExt.usrCheckGiroNbr.IsEqual<@P.AsString>>
         .View.Select(Base, row.usrCheckGiroNbr);


     BatchExt itemExt = item.GetExtension<BatchExt>();
     rowExt.usrCheckGiroNumber = itemExt.usrCheckGiroNumber;
   }
}
#endregion

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved