Check Box Customization

Userlevel 1

In acumatica project screen(PM301000) i have add two custome fields. those are UsrOnBudget and UsrCompletedPrec. i need to develop when i check UsrOnBudget check box get PMRevenueBudget.CuryAmount and divide by PMCostBudget.CuryAmount And that value show on UsrCompletedPrec field. Those To Customized Field locate in CT.ContractExt. How can I achieve it?


Best answer by aaghaei 17 May 2024, 20:03

View original

2 replies

Userlevel 1

This is my code. actualRevenueAmount and actualCostQty  assigned their value as actualRevenueAmount + actualCostQty . Not give correct output

ex: PMRevenueBudget.CuryAmount = 20

      PMCostBudget.CuryAmount = 10


      actualRevenueAmount = 30

      actualCostQty = 30

using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects.CA;
using PX.Objects.CT;
using PX.Objects.PM;
using System.Linq;

namespace Lauges
public class ProjectEntryExt : PXGraphExtension<ProjectEntry>
#region Event Handlers

protected void _(Events.FieldUpdated<ContractExt.usrOnBudget> e)
var row = e.Row as Contract;

if (row != null && (bool)e.NewValue == true)


private decimal CalculateCompletedPerc(Contract contract)

decimal actualRevenueAmount = PXSelect<PMRevenueBudget,
Where<PMRevenueBudget.projectID, Equal<Current<Contract.contractID>>>>
.Select(Base).FirstTableItems.Sum(rb => rb.CuryAmount ?? 0);

decimal actualCostQty = PXSelect<PMCostBudget,
Where<PMCostBudget.projectID, Equal<Current<Contract.contractID>>>>
.Select(Base).FirstTableItems.Sum(cb => cb.CuryAmount ?? 0);

decimal percentage = (actualCostQty / actualRevenueAmount) * 100;

if (actualRevenueAmount != 0)
contract.GetExtension<ContractExt>().UsrCompletedPercentage = percentage;

return percentage;

return 0;





Userlevel 7
Badge +9

@tharinduweerasooriya90  I can see two issues in your code

  1. In the Field Updated Event Handler I see the first parameter is missing. It should be something like _(Events.FieldUpdated<Contract, ContractExt.usrOnBudget> e) 
  2. In CalculateCompletedPerc your las line of code is never going to be executed as you are returning anyways before that point.

Also I suggest

  1. move your decimal percentage = (actualCostQty / actualRevenueAmount) * 100; into the if so you won’t get error in case you have actualRevenueAmount zero.
  2. assign either zero or your calculated formula to a variable and return at the end of your method
  3. Use Base.Projects.Update(contract) as you already have it initiated in the Base.
  4. Instead of using LINQ you can use GroupBy <AggregateTo<Sum<YourField>>> and tally your project revenue and cost.


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