Skip to main content
Answer

Data not displayed in run service contract billing screen

  • March 24, 2023
  • 5 replies
  • 84 views

Hi Guys, I’m trying to add custom column - contract Price field from service contract and display in run service contract billing screen.

I added the field in Screen editor customization. created the DAC, and graph but I’m not able to view the data in run service contract billing screen.

Below is my custom field.

 

DAC,

#region UsrContractTotal

        [PXDBDecimal]
        [PXUIField(DisplayName = "Contract Price")]
        public virtual decimal? UsrContractTotal { get; set; }
        public abstract class usrContractTotal : BqlDecimal.Field<usrContractTotal> { }
        #endregion

Graph,

Public class ContractPeriodToPostEntryExt : PXGraphExtension<CreateInvoiceByContractPost>
    {
        #region Event Handlers
        public static bool IsActive() => true;
        protected virtual void ContractPeriodToPost_ServiceContractID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = (ContractPeriodToPost)e.Row;
            if (row != null)
            {

                PXResultset<FSContractPeriodDet> objservicecont = PXSelectJoin<FSContractPeriodDet,
                                               InnerJoin<FSContractPeriod,
                                                        On<FSContractPeriod.serviceContractID, Equal<FSContractPeriodDet.serviceContractID>,
                                                           And<FSContractPeriod.contractPeriodID, Equal<FSContractPeriodDet.contractPeriodID>>>>,
                                               Where<FSContractPeriodDet.serviceContractID, Equal<Required<FSServiceContract.serviceContractID>>,
                                                     And<FSContractPeriod.status, Equal<FSContractPeriod.status.Active>>>>.Select(Base, row.ServiceContractID);

                decimal totalRecSum = 0m;
                foreach (var det in objservicecont)
                {
                    totalRecSum += ((FSContractPeriodDet)det[0]).RecurringTotalPrice ?? 0m;
                }
                row.GetExtension<ContractPeriodToPostKSExt>().UsrContractTotal = totalRecSum;
            }
        }
    }
}
#endregion

When i try to debug, I’m able to get the data in graph but not in the UI. Can anyone check where it is going wrong. 

For some reason I was not able to share my customization.

Best answer by Naveen Boga

@mice   Please use below code and check.

Also, you need to change the EVENT  like - ContractPeriodToPost_UsrContractTotal_FieldSelecting


 

protected virtual void ContractPeriodToPost_UsrContractTotal_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ContractPeriodToPost)e.Row;
if (row != null)
{

PXResultset<FSContractPeriodDet> objservicecont = PXSelectJoin<FSContractPeriodDet,
InnerJoin<FSContractPeriod,
On<FSContractPeriod.serviceContractID, Equal<FSContractPeriodDet.serviceContractID>,
And<FSContractPeriod.contractPeriodID, Equal<FSContractPeriodDet.contractPeriodID>>>>,
Where<FSContractPeriodDet.serviceContractID, Equal<Required<FSServiceContract.serviceContractID>>,
And<FSContractPeriod.status, Equal<FSContractPeriod.status.Active>>>>.Select(Base, row.ServiceContractID);

decimal totalRecSum = 0m;
foreach (var det in objservicecont)
{
totalRecSum += ((FSContractPeriodDet)det[0]).RecurringTotalPrice ?? 0m;
}
e.RetunValue = totalRecSum;
}
}
}
}

 

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • March 24, 2023

Hi @mice As you are using the FieldSelecting event, if you assign like below it may not populate the value.

 row.GetExtension<ContractPeriodToPostKSExt>().UsrContractTotal = totalRecSum;

There is minor you need to populate the value properly. Try below code instead of above code.

e.ReturnValue = totalRecSum;


  • Author
  • Freshman I
  • March 24, 2023

@Naveen Boga, still same result - its empty.

 

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • March 24, 2023

@mice   Please use below code and check.

Also, you need to change the EVENT  like - ContractPeriodToPost_UsrContractTotal_FieldSelecting


 

protected virtual void ContractPeriodToPost_UsrContractTotal_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e, PXFieldSelecting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ContractPeriodToPost)e.Row;
if (row != null)
{

PXResultset<FSContractPeriodDet> objservicecont = PXSelectJoin<FSContractPeriodDet,
InnerJoin<FSContractPeriod,
On<FSContractPeriod.serviceContractID, Equal<FSContractPeriodDet.serviceContractID>,
And<FSContractPeriod.contractPeriodID, Equal<FSContractPeriodDet.contractPeriodID>>>>,
Where<FSContractPeriodDet.serviceContractID, Equal<Required<FSServiceContract.serviceContractID>>,
And<FSContractPeriod.status, Equal<FSContractPeriod.status.Active>>>>.Select(Base, row.ServiceContractID);

decimal totalRecSum = 0m;
foreach (var det in objservicecont)
{
totalRecSum += ((FSContractPeriodDet)det[0]).RecurringTotalPrice ?? 0m;
}
e.RetunValue = totalRecSum;
}
}
}
}

 


  • Author
  • Freshman I
  • March 25, 2023

You are a STAR of Acumatica @Naveen Boga ...


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • March 25, 2023

@mice  I’m glad that I helped you and Thank you!!