Skip to main content

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

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)


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

 


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

 


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();
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
bPXString]
bPXUIField(DisplayName="Last Name")]

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

 


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
}

 


Thank you that worked like a charm...


Reply