Solved

Adding a new column to a grid


Good day

I please need some help in adding a new column to the Employee Time page.
The field would show the customers name next to the product that it is linked to, the project displays on the grid by default.
At the moment I cannot seem to add an additional column to the grid, I added it via a customization and the field does show in the customization project but when previewing the page the column is not in the grid
Please assist me with this

icon

Best answer by Naveen Boga 16 April 2021, 22:10

View original

14 replies

Userlevel 7
Badge +17

Hi, @LeeRoy57 You want to add the field in the Employee Time Activities screen(EP307000)?
Can you please us know, what field you want in the grid?
 

Hi Naveen

Thank you for your reply

I would like to add the field to the Employee Time Card page
 

If you search for a Project on the grid the field that I would like to add is in the possible projects list
 

I would please like some help to display this field in the grid also next to the project column

Userlevel 7
Badge +17

Hi, @LeeRoy57,

Understood. you would like to add a new field in the Project Selector field.  The below article will help you a lot to add the field in the selector grid.

https://www.info-sourcing.com/how-to-add-fields-to-acumatica-selector-lookup-no-coding/

 

This customerID field is located on PMProject DAC. The grid only takes fields from Summary view.

You will need to modify it to include that field in order to add it there.

Userlevel 7
Badge +17

Hi, @LeeRoy57  Sorry it was my bad, I thought other way round.

You want to add a new field i.e. Customer after the project. Please find the sample code and attached screenshot for your reference.

 

Hope this helps!!

 public class EPTimeCardSummaryWithInfoExt : PXCacheExtension<EPTimeCardSummaryWithInfo>
{

[CustomerActive(
typeof(Search<BAccountR.bAccountID, Where<True, Equal<True>>>),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Customer.acctName),
Filterable = true)]
[PXUIField(DisplayName = "Customer ID")]
public int? UsrCustomerID { get; set; }
public abstract class usrCustomerID : PX.Data.BQL.BqlInt.Field<usrCustomerID> { }

}


public class TimeCardMaintExt : PXGraphExtension<TimeCardMaint>
{

protected virtual void EPTimeCardSummaryWithInfo_ProjectID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(sender, e);
EPTimeCardSummaryWithInfo row = (EPTimeCardSummaryWithInfo)e.Row;
if (row != null)
{
PMProject objPMProject = PXSelect<PMProject, Where<PMProject.contractID, Equal<Required<PMProject.contractID>>>>.Select(Base, row.ProjectID);
if (objPMProject != null)
{
row.GetExtension<EPTimeCardSummaryWithInfoExt>().UsrCustomerID = objPMProject.CustomerID;
}
}
}
}

 

 

 

 

Hi Naveen

Thank you very much this is exactly what I am trying to accomplish.
I please need some further assistance from you with adding the DAC extension in my customization.
Below you will see I have already added the DAC extension for the TimeCardMaint class and added the code that you have supplied. 
Please advise me hoe I should add the EPTimeCardSummaryWithInfo DAC so that it can be linked to the page and available.

Here I have added the EPTimeCardSummaryWithInfo class under DATA ACCESS tab and created the new Customer ID field
 

 

Then under the CODE tab I have added the following code so far as in your code
 


 

Please advise me where I should add the code for the EPTimeCardSummaryWithInfoExt class so that the pages picks it up when publishing?
Please see my error at the moment when I publish the customization
 

Please assist me with this
Thank you very much in advance​​​​​​​

Userlevel 7
Badge +17

@LeeRoy57 Can you please this customization package here

Hi Naveen

Please see my attached customization.
I can’t seem to get this piece of code correct please assist me so that the customer name displays in grid and not the ID.
Thank you very much

Userlevel 7
Badge +17

Hi @LeeRoy57 I have resolved that issue, please find the latest package attached here.

 

Hi Naveen

Thank you very much for your help!
It’s much appreciated.
Hope you have a great day 

Regards,
Lee’Roy

Hi Naveen

Sorry I please need your assistance again as I need to change the field one more time.
At the moment the field is displaying the customer ID with the part of the customer abbreviation in front but I would please like to load the customer full name in there
Please see my pictures

Here is what you helped me with to load the ID with the abbreviation 
 


 I would please like your assistance again to replace that ID with the full name
 


Please advise me on this
Thank you

Regards,
Lee’Roy​​​​​​​

Userlevel 7
Badge +17

 

Hi @LeeRoy57 Here is the code to bring the Customer Name in “Employee Time Card” screen.

 

Add the database filed in the database  for the Customer Name

Graph Extension:

public class TimeCardMaint_Extension : PXGraphExtension<TimeCardMaint>
{
#region Event Handlers

protected virtual void EPTimeCardSummaryWithInfo_ProjectID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (EPTimeCardSummaryWithInfo)e.Row;

if (row != null)
{
PMProject objPMProject = PXSelect<PMProject, Where<PMProject.contractID, Equal<Required<PMProject.contractID>>>>.Select(Base, row.ProjectID);

if (objPMProject != null)
{
Customer obj = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, objPMProject.CustomerID);
if (obj != null)
row.GetExtension<EPTimeCardSummaryExt>().UsrCustomerName = obj.AcctName;
}
}
}

#endregion
}

DAC Extension:

public class EPTimeCardSummaryExt : PXCacheExtension<EPTimeCardSummaryWithInfo>
{

#region UsrCustomerName
[PXDBString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Customer Name")]
public string UsrCustomerName { get; set; }
public abstract class usrCustomerName : PX.Data.BQL.BqlString.Field<usrCustomerName> { }
#endregion

}

.aspx Page:

<px:PXGridColumn DataField="UsrCustomerName" Width="160" CommitChanges="True" />

 

Hi @LeeRoy57 Here is the code to bring the Customer Name in “Employee Time Card” screen.

 

Add the database filed in the database  for the Customer Name

Graph Extension:

public class TimeCardMaint_Extension : PXGraphExtension<TimeCardMaint>
{
#region Event Handlers

protected virtual void EPTimeCardSummaryWithInfo_ProjectID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (EPTimeCardSummaryWithInfo)e.Row;

if (row != null)
{
PMProject objPMProject = PXSelect<PMProject, Where<PMProject.contractID, Equal<Required<PMProject.contractID>>>>.Select(Base, row.ProjectID);

if (objPMProject != null)
{
Customer obj = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, objPMProject.CustomerID);
if (obj != null)
row.GetExtension<EPTimeCardSummaryExt>().UsrCustomerName = obj.AcctName;
}
}
}

#endregion
}

DAC Extension:

public class EPTimeCardSummaryExt : PXCacheExtension<EPTimeCardSummaryWithInfo>
{

#region UsrCustomerName
[PXDBString(50, IsUnicode = true)]
[PXUIField(DisplayName = "Customer Name")]
public string UsrCustomerName { get; set; }
public abstract class usrCustomerName : PX.Data.BQL.BqlString.Field<usrCustomerName> { }
#endregion

}

.aspx Page:

<px:PXGridColumn DataField="UsrCustomerName" Width="160" CommitChanges="True" />

 

Thanks Naveen!
That worked 100%

Userlevel 7
Badge +17

Awesome..  Thanks for sharing an update :)  

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