Skip to main content

Hi Team,

I've added a custom field named "UsrContractAmount" to our project. This field is designed to calculate a value based on certain criteria.

Below is the code related to this field:

 

#region UsrContractAmount
    ÂPXDBDecimal]
     PXUIField(DisplayName="Contract Amount", Enabled = false)]

    public virtual Decimal? UsrContractAmount { get; set; }
    public abstract class usrContractAmount : PX.Data.BQL.BqlDecimal.Field<usrContractAmount> { }
#endregion
 

The calculation for this field is performed in the following method:

 

protected virtual void _(Events.RowSelected<PMProject> e) { var row = (PMProject)e.Row; var rowExt = PXCache<PMProject>.GetExtension<PMProjectExt>(row); PMProject project = e.Row; const int targetAccountGroupID = 35; const string targetGroupCD = "REVREC"; decimal sumContractAmount = 0; if (getBudgetLines == null) return; // Retrieve all the PMRevenueBudget records for the specific groupCD. foreach (PMRevenueBudget costBudget in PXSelectJoin<PMRevenueBudget, InnerJoin<PMAccountGroup, On<PMRevenueBudget.accountGroupID, Equal<PMAccountGroup.groupID>>>, Where<PMAccountGroup.groupCD, Equal<Required<PMAccountGroup.groupCD>>>> .Select(Base, targetGroupCD)) { // Check if the accountGroupID matches the target value (35). if (costBudget.AccountGroupID == targetAccountGroupID && costBudget.ProjectID == project.ContractID) { sumContractAmount += costBudget.CuryRevisedAmount ?? 0m; } }

 

However, I've encountered an issue where, upon adding this field to a generic inquiry in my project, the field value is not populating for all projects. It seems to be working only for certain generic inquiries.

In the project screen, the field is functioning correctly, but it is not working in the Generic Inquiry.

I would greatly appreciate any assistance or insights you can provide to help resolve this issue.

Best regards,

Sagar

@sagar07 The same goes here similar to my reply to your previous post. If you are updating a parent from child, you will need to:

  • Either loop on the associated child records and update the parent that can happen on the parent RowUpdated or RowPersisted event or Persist method.
  • Or you can utilize Acumatica’s SumCalc function of PXFormula attribute on the child field (it will work only if one field of all child records making up the parent record desired field) to track the child record changes and update the header instantly.

Reply