Listening for object changes that trigger events
It is possible that you want to listen for
a change in an object that does not automatically trigger an event if
you update it. For example, suppose that you want to listen for a change
to the User object (an
update of the address, perhaps). However, in this case, the User object itself does not contain
an address. Instead, PolicyCenter
stores addresses as an array on UserContact,
which is an extension of Person,
which is a subtype of Contact,
which points to User.
Therefore, updating an address does not directly in itself touch the
User object.
However, in an Event Message rule, you
can listen for the ContactChanged
event that PolicyCenter generates
every time that the address changes. The following example illustrates
this concept. (It prints out a message to the system console anytime
that the address changes. In actual practice, you would use a different
message destination, of course.)
USES
uses gw.api.util.ArrayUtil
CONDITION
//DestID 68 is the Console Message Logger
return messageContext.DestID == 68 and messageContext.EventName == "ContactChanged"
ACTION
var message = messageContext.createMessage( "Event: " + messageContext.EventName )
var contact = messageContext.Root as Contact
var fields = contact.PrimaryAddress.ChangedFields
print( ArrayUtil.toString( fields ) )
