Solved

Custom column in Run Service Contract Billing (FS501300) form doesn't dislpay dqata

  • 26 August 2022
  • 4 replies
  • 117 views

Hello,

I’m trying to resolve the following issue: custom column added to the grid contains no data.

Here are the details.

I am trying to customize the Run Service Contract Billing (FS501300) form to add Organization ID column into its Contracts grid.

To do that I extended the ContractPeriodToPost DAC for the grid based on the following article: https://blog.zaletskyy.com/post/2020/03/09/post100 .
My extension is as following.

using PX.Data;

using PX.Data.BQL;

using PX.Objects.GL;

namespace PX.Objects.FS

{

    public class ContractPeriodToPostExt : PXCacheExtension<ContractPeriodToPost>

    {

        public static bool IsActive() => true;

        #region UsrCompanyID

        [PXInt]

        [PXUIField(DisplayName = "Organization ID")]

        [PXDBScalar(typeof(Search<Branch.organizationID, Where<Branch.branchID, Equal<ContractPeriodToPost.branchID>>>))]

        public virtual int? UsrCompanyID { get; set; }

        public abstract class usrCompanyID : BqlInt.Field<usrCompanyID> { }

        #endregion

    }

}

Then using Screen Editor, I added UsrCompanyID (Organization ID) control of type NumberEdit to the Grid.
As a result, the Contracts grid now has the Organization ID column, however it doesn’t contain any data.

The grid though successfully displays all the data for all the other columns.

What should I do to display data in the Organization ID column?

Thank you!

 

icon

Best answer by Leonardo Justiniano 29 August 2022, 18:21

View original

4 replies

Userlevel 6
Badge +4

Hi @ntabunidze57 

 

PXDBScalar should work in your scenario (A Projection). PXDBScalar & Projections

However and alternative to it is using PXUnboundDefault instead

 

#region UsrCompanyID

[PXInt]
[PXUIField(DisplayName = "Organization ID")]
[PXUnboundDefault(typeof(Search<Branch.organizationID, Where<Branch.branchID, Equal<Current<ContractPeriodToPost.branchID>>>>))]
public virtual int? UsrCompanyID { get; set; }
public abstract class usrCompanyID : BqlInt.Field<usrCompanyID> { }

#endregion

Note that ContractPeriodToPost.branchID reference requires the Current<> one. This is because PXUnboundDefault is resolved after the record is retrieved, executing the specified BQL for that record.

 

Thank you, Leonardo!

[PXUnboundDefault] works for me.

Userlevel 5
Badge +2

@Leonardo Justiniano the alternative approach that we had discussed via events is this one:


protected virtual void _(Events.FieldSelecting<DACExt.usrCompanyID> e)
{
if (e.Row == null)
{
return;
}

Branch branchRow = PXSelect<Branch,
Where<Branch.branchID, Equal<Required<Branch.branchID>>>>
.Select(this.Base, ContractPeriodToPost.branchID);

if (branchRow != null)
{
e.ReturnValue = branchRow.OrganizationID;
}
}

I have not tested this logic. It’s an adaptation from similar logic that we have implemented in the past.

 

Having said that, your approach via PXUnboundDefault attribute is better.

Userlevel 6
Badge +4

@Fernando Amadoz 

 

Thanks! Alternative approaches are super valuable.

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