The Attributes tab identifies the attributes in the repository being monitored for changes or to be logged anytime there is a change:
This list of attributes excludes the multi-language attributes to be processed for language translation – these attributes are defined in the named CN_Translation_Registry record.
CN_Attribute_All_Action - Specifies the action to be taken on all attributes in the repository. This eliminates the need to list every attribute in the CN_Attribute_Name attribute. If a new attribute is added to the repository, it will automatically be included:
- Changed – take action on a change being made to any attribute in the repository but only log attributes that have actually changed. If specific attributes should always be logged, they must be listed in the CN_Attribute_Name list with the corresponding CN_Attribute_Log_Always set to Yes.
- Changed with Multi-Language – take action on a changed being made to any attribute in the repository including the non-default Multi-Language extensions.
- Log Always – log the values of each attribute in the repository. If this option is set, at least one attribute must be specified in the CN_Attribute_Name list to trigger the notification processing.
- Log Always with Multi-Language – log the values of each attribute in the repository including all active language extensions for Multi-Language attributes. If this option is set, at least one attribute must be specified in the CN_Attribute_Name list to trigger the notification processing.
CN_Attribute_Name - The attribute CN_Attribute_Name identifies each attribute to be monitored or logged. Changes to attributes not in this list will be ignored unless CN_Attribute_All_Action is set. Required if CN_Attribute_All_Action is not set.
CN_Attribute_Log_Always - Specifies whether the corresponding attribute in the CN_Attribute_Name list is always logged (if other attributes in the list have changed) or only when there is a change. If the log always attribute has not changed, the Old Value and New Value will be the same. If CN_Attribute_All_Action is set, attributes listed here will override the All Action setting. For example, if CN_Attribute_All_Action is set to "Changed", attributes will only be logged if changed, unless listed here with CN_Attribute_Log_Always being set to "Yes".
CN_Attribute_Language – Optionally defines the language extension for each attribute being monitored (if it is not the default language) for multi-language attributes. For example, to monitor changes to the Spanish version of Long Description, the CN_Attribute_Language would be set to "es". The "All" option indicates that all active languages are to apply. Unless the CN_Attribute_All_Action attribute is set to "Changed with Multi-Language" or "Log Always with Multi-Language", the only way to trigger or log non-default language values is by explicitly listing the attribute and language extension (with All indicating all active languages should be included):
CN_External_Attributes_SQL – Optional SQL Statement that returns a single row of additional data (from other repositories) that is connected to the changed record. Each column in the SELECT statement is captured and logged as additional attributes. This allows for contextual information to be recorded at the time of the original record was changed since retrieving the linked values at report time may be different from when the original change was logged.
The SQL statement may contain any valid SQL for a SELECT query. Data from the changed record can be included in the statement through named references (denoted by the attribute name surrounded by double pipe-characters). These references are resolved before the SQL statement is run. If the value needs to be treated as a character value in the query, it must be surrounded by single quotes.
For example, if the EnterWorks data model has a Product repository linked to an Item repository by an alphanumeric ID and changes to Item records need to record the Product Group Name (from the Product record), the following SQL can be used to retrieve that information:
SELECT Product_Group_Name FROM _PIM_Product_Staging WHERE Product_ID = '||Product ID||'
All external attributes will show the same value for the Old and New values in the log.
The external attributes are populated prior to the processing of the conditions on the Conditions tab. This means an external attribute can be used to determine whether the CN_Registry is processed. It also means the external attribute SQL is always run so its performance/efficiency needs to be a primary consideration.
If the name of a column in the query matches the name of an attribute in the monitored repository, the external attribute should be aliased to something unique. For example, if the Product repository and the Item repository both have a "Publication Status" attribute and both need to be logged, the SQL statement must alias the attribute:
SELECT Publication_Status as [Product Publication Status], Product_Group_Name FROM PIM_Product_Staging WHERE Product_ID = '||Product ID||'
If the SELECT statement may return more than one row, only the first record retrieved will be used – the subsequent records will be ignored. If the values of the fields being retrieved may be different, the SQL must be structured such that the value from the desired record is returned first in the results.
In addition to referencing any attribute in the monitored repository, the SQL may also
contain the date and time stamp of when the change was made by specifying the reserved
reference ||CURRENT_DATETIME||
. This is resolved to the current date
and time in the format yyyyMMddHHmmssSS. Alternative formats can be specified by using
the Java class SimpleDateFormat's notation. For example, to only include the date in
mm/dd/yyyy format, the reference must be
||CURRENT_DATETIMEMM/dd/yyyy||
.