Skip to main content
Solved

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

  • August 26, 2022
  • 4 replies
  • 138 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!

 

Best answer by Leonardo Justiniano

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.

 

4 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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.

 


  • Author
  • Freshman I
  • August 29, 2022

Thank you, Leonardo!

[PXUnboundDefault] works for me.


Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+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.


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

@Fernando Amadoz 

 

Thanks! Alternative approaches are super valuable.