onItemBeforeWrite - event of object PmData

The event fires before writing into (the change of) the value of one variable defined on the Data page.
pMe(Object) Reference to the PROMOTIC object where the event rises.
pEvent(Object) A referrence to object describing detailed information about the specific event.
pEvent.Item - (Object) The Var object containing the information about the variable, in which some writing (change) occurred
pEvent.NewVal - (Variant) New value of the variable. The variable will have this value after the event.

To achieve calling this event for the specific variable, it is necessary to enable the calling explicitly in the variable (see the configurator "ExtWriteAction > Data extension configuration: ExtWriteAction > Event "onItemBeforeWrite""). There it is also defined if the event fires before each writing or before each change of the value.

If the fireing is enabled for each variable and writing into (the change of) all variables occurs at a time, then the event fires for each variable separately!

The usage of this event is appropriate, for example, to filter written values. The pEvent.NewVal parameter is defined for reading and writing. If a new value is written into this parameter, then the value from the parameter is written as a matter of fact into the object variable (after ending this event).

Caution 1:

It is recommended to use this event only for special cases. When this event is enabled, the values are written asynchronously, i.e. this event does not execute the write command instantly, but later, after the active script is finished.

Caution 2:

The event fires only if the real writing is performed (e.g. object.Item(0)=3) into the variable - let's mark it A. But if the data binding (during the reading) to another variable B (in another object) is defined in the variable A and it is written into the variable B, then the variable A doesn't know about the change and thus the event not fires (the variable A does know about the change only when it is read by someone - data binding is then "performed" - but the event not fires again !).

See also:
The following script in the onItemBeforeWrite event dumps into the Debug_info item of the INFO system the information about the written value - it dumps the variable name where it will be written, the index of the variable and an old and new value of the variable.
VBScriptSelect and copy to clipboard

Pm.Debug "Name:" & pEvent.Item.Name
Pm.Debug "Index:" & pEvent.Item.Index
Pm.Debug "OldValue:" & pEvent.Item.Value
Pm.Debug "NewValue:" & pEvent.NewVal
PROMOTIC 8.3.30 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice