0
votes

I created 3 custom field on RQRequisition master dataview. Add FieldUpdated event for each custom fields which function are to sum value from those fields and then copying it to custom field on line dataview (RQRequisitionLine).

DAC Extension definition for RQRequisition:

//Non UI Field for UsrEngCost
[PXDBDecimal]
[PXDefault(TypeCode.Decimal, "0.0")]    

// definition for UsrCuryEngCost
[PXDBCurrency(typeof(RQRequisition.curyInfoID), typeof(RQRequisitionExt.usrEngCost))]
[PXUIField(DisplayName="Est. Eng. Cost")]    
[PXDefault(TypeCode.Decimal, "0.0")]

//Non UI Field for UsrShipCost
[PXDBDecimal]
[PXDefault(TypeCode.Decimal, "0.0")]

// definition for UsrCuryShipCost
[PXDBCurrency(typeof(RQRequisition.curyInfoID), typeof(RQRequisitionExt.usrShipCost))]
[PXUIField(DisplayName="Est. Ship. Cost")]
[PXDefault(TypeCode.Decimal, "0.0")]

//Non UI Field for UsrCleCost
[PXDBDecimal]
[PXDefault(TypeCode.Decimal, "0.0")]

// definition for UsrCuryCleCost
[PXDBCurrency(typeof(RQRequisition.curyInfoID), typeof(RQRequisitionExt.usrCleCost))]
[PXUIField(DisplayName="Est. Clear. Cost")]
[PXDefault(TypeCode.Decimal, "0.0")]

DAC Extension definition for RQRequisitionLine:

//Non UI Field for UsrAddCost
[PXDBDecimal]
[PXDefault(TypeCode.Decimal, "0.0")]

// definition for UsrCuryAddCost
[PXDBCurrency(typeof(RQRequisitionLine.curyInfoID), typeof(RQRequisitionLineExt.usrAddCost))]
[PXUIField(DisplayName="Additional Cost")]
[PXDefault(TypeCode.Decimal, "0.0")]

here is the code of FieldUpdated event:

protected virtual void RQRequisition_UsrEngCost_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
  RQRequisition row = (RQRequisition)e.Row;
  if (row == null) return;

  RQRequisitionExt rowExt = PXCache<RQRequisition>.GetExtension<RQRequisitionExt>(row);

  RQRequisitionLine reqLine = ReqLines.Current;
  RQRequisitionLineExt reqLineExt = PXCache<RQRequisitionLine>.GetExtension<RQRequisitionLineExt>(reqLine);

  reqLineExt.usrCuryAddCost = rowExt.usrCuryEngCost + rowExt.usrCuryShipCost + rowExt.usrCuryCleCost;
  row.Update(reqLine);

}

publish and get error:

error: 'usrCuryAddCost': cannot reference a type through an expression; try 'PX.Objects.RQ.RQRequisitionLineExt.usrCuryAddCost' instead in file: Code#RQRequisitionEntry(41) error: 'usrCuryEngCost': cannot reference a type through an expression; try 'PX.Objects.RQ.RQRequisitionExt.usrCuryEngCost' instead in file: Code#RQRequisitionEntry(41)

Kindly need your advice.

1

1 Answers

0
votes

'usrCuryAddCost' and 'usrCuryEngCost' (first character lowercase) fields should be declared as abstract class types in the DAC extension.

'UsrCuryAddCost' and 'UsrCuryEngCost' (first character uppercase) should be declared as property types alongside the abstract classes in the DAC extension.

You use the abstract class (first character lowercase) in BQL queries, type parameters and attributes.

You use the properties (first character uppercase) when you need to access the property value of a field.

Have you tried this: reqLineExt.UsrCuryAddCost = rowExt.UsrCuryEngCost + rowExt.UsrCuryShipCost + rowExt.UsrCuryCleCost;

Are these properties declared in the extension DAC?