Solved

Adding Last Name to Payroll Payment Screen

  • 14 April 2022
  • 6 replies
  • 96 views

Userlevel 3
Badge +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

icon

Best answer by Leonardo Justiniano 16 April 2022, 01:27

View original

6 replies

Userlevel 6
Badge +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)

Userlevel 3
Badge +1

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

 

Userlevel 6
Badge +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);
}
}
}

 

Userlevel 3
Badge +1

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

 

Userlevel 6
Badge +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
}

 

Userlevel 3
Badge +1

Thank you that worked like a charm...

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