trigger preSerialize

System trigger that processes an occurrence before it is saved from a component into a disconnected record set (XML, JSON, or Struct).

Declaration: trigger preSerialize
Applies to: Entity
Activation: Activated immediately before an occurrence is saved from a component into a disconnected record set.
Default behavior: None
Behavior upon completion: Setting $status to <0 prevents the occurrence from being saved to the disconnected record set.

Setting $status has no other effect on subsequent trigger processing.

Description

You can used this trigger to tune the execution of the xmlsave, websave, and componentToStruct ProcScript commands.

For example, an occurrence can be excluded from the save; or the value for a derived field can be calculated.

Calculating Values

The following code loops through all the ORDERLINE occurrences an ORDERS, to calculate the TOTAL value.

trigger preSerialize
TOTAL.ORDERS = 0 ;initialize field value
forentity "ORDERLINE" ;loop through each ORDERLINE entity
  LINE_TOTAL.ORDERLINE = UNIT_PRICE.ORDERLINE * QUANTITY.ORDERLINE ;calculate the LINE_TOTAL
  TOTAL.ORDERS += LINE_TOTAL.ORDERLINE ;calculate the TOTAL
endfor
end; preSerialize

Related Topics