Sunday 2 October 2016

ATG | Configure Last-Modified Property for repository items

Sometimes we need to persist the information, when a repository item was most recently modified. In ATG there is a way to configure last-modified property for item descriptor. 



Follow below steps to configure last-modified property for a given item-descriptor.

1. The item descriptor must contain a date or timestamp property that stores the last-modified value. This property must be persistent (add column in one of the existing table) and single-valued.

   <property name="lastActivity" data-type="timestamp"/>

2. The item descriptor sets the last-modified-property attribute to the name of the last-modified property (defined in above step).

    <item-descriptor name="customerServiceArticle" last-modified-property="lastActivity">

3. The item descriptor sets the updateLastModified <attribute> (attribute of item descriptor) element to true.

<attribute name="updateLastModified" value="true"/>

Example item descriptor (Only demonstrating last modified property).
==========================================================================
<item-descriptor name="customerServiceArticle" last-modified-property="lastActivity">

    <attribute name="updateLastModified" value="true"/>

    <table name="customer_articles" type="primary">
        <property name="lastActivity" data-type="timestamp"  column-name="last_updated"/>
    </table>

</item-descriptor>
 =========================================================================

Note : This property is automatically (no code required) updated with the current time when the item is added or updated.

No comments:

Post a Comment