Skip to main content
Solved

Adding Last Name to Payroll Payment Screen


greglang
Varsity I
Forum|alt.badge.img+1

I am trying to add the Employees last name to the payroll Possessing screen so I can sort the payments by this field.  I have tried to follow some instructions to get this done but can not get my code extension to process.  Can someone take a look at it and tell me what I am doing wrong.

using PX.Data.BQL.Fluent;
using PX.Data.EP;
using PX.Data.CR;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.PR;
using PX.Objects.CR;
using PX.Objects;
using System.Collections.Generic;
using System;

namespace PX.Objects.PR
{
  public class PRPaymentExt : PXCacheExtension<PX.Objects.PR.PRPayment>
  {
    #region UsrLastname
    [PXDBString(255)]
[PXUIField(DisplayName="Last Name")]
[PXFormula(typeof(Selector<PRPayment.EmployeeID, Contact.bAccountID>))]
[PXSelector(typeof(Search<Contact.bAccountID>),
            SubstituteKey = typeof(Contact.LastName)))]
    public virtual string UsrLastname { get; set; }
    public abstract class usrLastname : PX.Data.BQL.BqlString.Field<usrLastname> { }
    #endregion
  }

Thanks in advance!

 

Greg

Best answer by Leonardo Justiniano

Greg,

I think we should keep this simple. Please just undo documentList approach and keep applying PXDBScalar. The first attempt failed because the links were wrong.

 

public sealed class PRPaymentExt : PXCacheExtension<PRPayment>
{
#region UsrLastname
  [PXString]
  [PXUIField(DisplayName = "Last Name")]
  [PXDBScalar(typeof(
      Search2<Contact.lastName, 
      InnerJoin<BAccount, On<BAccount.defContactID, Equal<Contact.contactID>>>,
      Where<BAccount.bAccountID, Equal<PRPayment.employeeID>>>))]
   public string UsrLastname { get; set; }
   public abstract class usrLastname : PX.Data.BQL.BqlString.Field<usrLastname> { }
#endregion
}

 

View original
Did this topic help you find an answer to your question?

6 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi Greg

Can you try 

[PXDBScalar(typeof(Search<Contact.LastName, Where<Contact.bAccountID, Equal<PRPayment.EmployeeID>>>))]

Instead of PXFormula

Also, you might just need to have that field unbound (PXString)


greglang
Varsity I
Forum|alt.badge.img+1
  • Author
  • Varsity I
  • 61 replies
  • April 14, 2022

Still coming up with a blank field on the screen.  How would I change it to unbound text?

namespace PX.Objects.PR
{
  public class PRPaymentExt : PXCacheExtension<PX.Objects.PR.PRPayment>
  {
    #region UsrLastname
    [PXString]
    [PXUIField(DisplayName="Last Name")]
    [PXDBScalar(typeof(Search<Contact.lastName, Where<Contact.bAccountID, Equal<PRPayment.employeeID>>>))]
    public virtual string UsrLastname { get; set; }
    public abstract class usrLastname : PX.Data.BQL.BqlString.Field<usrLastname> {}
    #endregion
  }
      }

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Apologies Greg,

It did not work because it has a method

(...\App_Data\CodeRepository\PX.Objects.PR\PRDocumentProcess.cs)

You have to override 

public class PRDocumentProcess_Extension : PXGraphExtension<PRDocumentProcess>
{
   public delegate IEnumerable DocumentListDel();
   [PXOverride]
   public IEnumerable documentList(DocumentListDel delDocumentList)
   {
      List<object> result = delDocumentList()
      foreach(PRPayment line in result)
      {
         line.UsrLastName = GetLastName(line.EmployeeID);
      }
   }
}

 


greglang
Varsity I
Forum|alt.badge.img+1
  • Author
  • Varsity I
  • 61 replies
  • April 15, 2022

I see…  Think I have a type here that I can’t seem to figure out though.  I’m getting a CS1002 error for the line List<object> result = delDocumentList()

 

using PX.Data.BQL.Fluent;
using PX.Data.EP;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.PR;
using PX.Objects.CR.MassProcess;
using PX.Objects.CR.Workflows;
using PX.Objects.CR;
using PX.Objects;
using System.Collections.Generic;
using System;

namespace PX.Objects.PR
{
  public class PRDocumentProcess_Extension : PXGraphExtension<PRDocumentProcess>
  {
   public delegate IEnumerable DocumentListDel();
   [PXOverride]
   public IEnumerable documentList(DocumentListDel delDocumentList)
   {
      List<object> result = delDocumentList()
      foreach(PRPayment line in result)
      {
         line.UsrLastName = GetLastName(line.EmployeeID);
      }
   }
  }
  public class PRPaymentExt : PXCacheExtension<PX.Objects.PR.PRPayment>
  {
    #region UsrLastname
    [PXString]
    [PXUIField(DisplayName="Last Name")]

    [PXDBScalar(typeof(Search<Contact.lastName, Where<Contact.bAccountID, Equal<PRPayment.employeeID>>>))]
    public virtual string UsrLastname { get; set; }
    public abstract class usrLastname : PX.Data.BQL.BqlString.Field<usrLastname> {}
    #endregion
  }
      }

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Greg,

I think we should keep this simple. Please just undo documentList approach and keep applying PXDBScalar. The first attempt failed because the links were wrong.

 

public sealed class PRPaymentExt : PXCacheExtension<PRPayment>
{
#region UsrLastname
  [PXString]
  [PXUIField(DisplayName = "Last Name")]
  [PXDBScalar(typeof(
      Search2<Contact.lastName, 
      InnerJoin<BAccount, On<BAccount.defContactID, Equal<Contact.contactID>>>,
      Where<BAccount.bAccountID, Equal<PRPayment.employeeID>>>))]
   public string UsrLastname { get; set; }
   public abstract class usrLastname : PX.Data.BQL.BqlString.Field<usrLastname> { }
#endregion
}

 


greglang
Varsity I
Forum|alt.badge.img+1
  • Author
  • Varsity I
  • 61 replies
  • April 19, 2022

Thank you that worked like a charm...


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings