Skip to main content
Answer

How to : auto update otomatic value field ?

  • November 11, 2021
  • 8 replies
  • 268 views

yanuaralfianus37
Jr Varsity II

hi, i want to ask, what event handler can used to auto update otomatic value field after click order number ?

Example : 

 

after click this in GI

 

field “Available Shipment” will auto update value “3” (formula: Quantity - kuota pengiriman)

Thanks.

Best answer by Naveen Boga

@yanuaralfianus37  It should be PXDecimal but NOT PXDBDecimal

 

Just like below.


[PXDecimal]
[PXDBCalced(typeof(Sub<SOLine.orderQty, SOLineExt.kuotapengiriman>), typeof(decimal))]
[PXUIField(DisplayName = "Available for Shipment")]

 

 

8 replies

Vinay Koppula
Semi-Pro II
Forum|alt.badge.img+1
  • Semi-Pro II
  • November 11, 2021

Decorate the Formal attribute on the Available shipment field something like below 

[PXFormula(typeof(Sub<Soline.Qty, Soline.kuotaPengiriman>))]

 

Happy Coding!


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • November 11, 2021

Hi @yanuaralfianus37  I agree with Vinay and here are more details. Please find the details below.

  •  PXFormula attribute will work both bound and unbound fields but the PXFormula will NOT will not populate value for the existing records/documents. Until we go and modify the Qty or kuotapengiriman fields “Available for Shipment” will not be updated.

If Available for Shipment field is only display purpose and if it is unbound field I recommend you go with PXDBCalced attribute, this will work for existing records as well as new records.

 

Here is sample example for your reference. 

 public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region UsrAvailableForShipment
[PXDecimal]
[PXDBCalced(typeof(Sub<SOLine.orderQty, SOLineExt.kuotapengiriman>), typeof(decimal))]
[PXUIField(DisplayName = "Available for Shipment")]
public virtual decimal? UsrAvailableForShipment { get; set; }
public abstract class usrAvailableForShipment : PX.Data.BQL.BqlDecimal.Field<usrAvailableForShipment> { }
#endregion
}

 


yanuaralfianus37
Jr Varsity II

Decorate the Formal attribute on the Available shipment field something like below 

[PXFormula(typeof(Sub<Soline.Qty, Soline.kuotaPengiriman>))]

 

Happy Coding!

hi @Vinay K thanks for the code :thumbsup:

 

Hi @yanuaralfianus37  I agree with Vinay and here are more details. Please find the details below.

  •  PXFormula attribute will work both bound and unbound fields but the PXFormula will NOT will not populate value for the existing records/documents. Until we go and modify the Qty or kuotapengiriman fields “Available for Shipment” will not be updated.

If Available for Shipment field is only display purpose and if it is unbound field I recommend you go with PXDBCalced attribute, this will work for existing records as well as new records.

 

Here is sample example for your reference. 

 public class SOLineExt : PXCacheExtension<PX.Objects.SO.SOLine>
{
#region UsrAvailableForShipment
[PXDecimal]
[PXDBCalced(typeof(Sub<SOLine.orderQty, SOLineExt.kuotapengiriman>), typeof(decimal))]
[PXUIField(DisplayName = "Available for Shipment")]
public virtual decimal? UsrAvailableForShipment { get; set; }
public abstract class usrAvailableForShipment : PX.Data.BQL.BqlDecimal.Field<usrAvailableForShipment> { }
#endregion
}

 

hi @Naveen B thanks for the information, i want to ask, how to convert type data if one of field in PXDBCalced is Int ?.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • November 12, 2021

Hi @yanuaralfianus37  PXDBCalced attribute will calculate and returns the decimal value.

Can you please share your Available For Shipment DAC field here.


yanuaralfianus37
Jr Varsity II

Hi @Naveen B, this all SS

 

 

i got this error after open SO


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • November 12, 2021

@yanuaralfianus37  It should be PXDecimal but NOT PXDBDecimal

 

Just like below.


[PXDecimal]
[PXDBCalced(typeof(Sub<SOLine.orderQty, SOLineExt.kuotapengiriman>), typeof(decimal))]
[PXUIField(DisplayName = "Available for Shipment")]

 

 


yanuaralfianus37
Jr Varsity II

@yanuaralfianus37  It should be PXDecimal but NOT PXDBDecimal

 

Just like below.


[PXDecimal]
[PXDBCalced(typeof(Sub<SOLine.orderQty, SOLineExt.kuotapengiriman>), typeof(decimal))]
[PXUIField(DisplayName = "Available for Shipment")]

 

 

Hi @Naveen B Thanks for help, This is topic is solved :thumbsup_tone2: .


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • November 12, 2021

@yanuaralfianus37 Great :) Thanks for sharing the update.