# $audit
This keyword allows to keep track of changes in instances.
# Installation:
cob-cli customize audit
# Usage:
$audit.[creator|updater].[username|uri|time]<([ignoreRefs:true|false])>
This keyword can be used within a definition in one of two options: $audit.creator
or $audit.updater
. Each of these options accepts one of three possible types of arguments: username
, uri
, or time
*. There are thus six possible use case combinations:
keyword | Description |
---|---|
$audit.creator.username | when a user creates a new definition record, the value of this field will be filled with the username of that user. |
$audit.creator.uri | when a user creates a new definition record, the value of this field will be filled with the UserM reference of that user. |
$audit.creator.time | when a user creates a new definition record, the value of this field will be filled with the current date and time. |
$audit.updater.username | whenever an existing record is saved and one or more record fields were changed, the value of that field will be updated with the username of the person who saved that change. |
$audit.updater.uri | whenever an existing record is saved and one or more record fields were changed, the value of that field will be updated with the UserM reference of that user. |
$audit.updater.time | whenever an existing record is changed and these changes are saved, the value of that field will be updated with the date and time when these changes were saved. |
Parameter | Description |
---|---|
ignoreRefs | can be defined as true or false - with the default value being false . This parameter determines whether to apply an audit when a referenced field in the parent definition is modified. For example, $audit.updater.username([ignoreRefs:true]) indicates that if the referenced field in the parent definition changes, these changes will not be audited in the current definition |
Some Consideration about this keyword:
- When using
$audit.updater
, clicking the Save button is not enough for the value of the fields that have this option to be updated. A de facto change must occur in one or more record fields for the server to update the value of the field. - Records created or updated in IntegrationM do not support fields of type
$audit
- both in the$audit.creator
and in the$audit.updater
option. - Do note that the
time
argument only works as expected when used in a field along with the$datetime
keyword - i.e.,$datetime $audit.creator.time
or$datetime $audit.updater.time
. Otherwise, instead of a date and a time, the platform will fill the instance field with a number (the number of miliseconds since 1/1/1970). - Because this keyword works simultaneously both on the front-end as well as on the back-end, if a user does a group edition of two or more records at once all these records will be immediately updated with that person's username.
# Example:
# 1. Keeping track of the last user that changed the instance
$extRef(userm, /userm/user/search?q={{this}}*) $audit.updater.uri
A typical usage scenario of this keyword is to use the updater.uri
option together with the $extRef
keyword, taking a UserM reference as an argument
# 2. Keeping track when the last change occur
$datetime $audit.updater.time