<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to update createdAt and updatedAt fields in your data type?</title><link>https://community.appian.com/discussions/f/data/13568/how-to-update-createdat-and-updatedat-fields-in-your-data-type</link><description>Hi, For best practice I have added a createdAt and updatedAt field in my CDT. This is generally good to have on several of my CDTs to trace activity in the future. 
 How do I save a date/time to these fields with system generated data at the time of form</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: How to update createdAt and updatedAt fields in your data type?</title><link>https://community.appian.com/thread/61588?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2018 15:17:12 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fbad5cae-9a88-4e1e-ac1e-688fa3051ccc</guid><dc:creator>Larry Nguyen</dc:creator><description>Something else you could also do is, instead of having createAt / updatedAt in your CDT, you can have the underlying database table written to have a CREATED_DATETIME / UPDATED_DATETIME field and in your database table schema specify the CREATED_DATETIME column to have a DEFAULT value of CURRENT_TIMESTAMP and the UPDATED_DATETIME column to have an ON UPDATE value of CURRENT_TIMESTAMP.  &lt;br /&gt;
&lt;br /&gt;
The nice thing about this is you no longer have to enforce providing values for these fields at the application level, so if a new developer wants to write to these tables, they don&amp;#39;t have to remember to fill in these values before writing to the table.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update createdAt and updatedAt fields in your data type?</title><link>https://community.appian.com/thread/61585?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2018 14:19:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:c9460f25-55a6-4daf-83f8-99ad3abc8402</guid><dc:creator>erics171</dc:creator><description>Thank you. This was very helpful&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to update createdAt and updatedAt fields in your data type?</title><link>https://community.appian.com/thread/61584?ContentTypeID=1</link><pubDate>Mon, 15 Oct 2018 13:55:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ca1b4525-4d62-4cd4-8563-4f53e971429e</guid><dc:creator>Joubin Izadi</dc:creator><description>One solution would be to have an &amp;quot;Update Audit Fields&amp;quot; node in your process model before your data write. &lt;br /&gt;
&lt;br /&gt;
Here, you could save &amp;quot;now()&amp;quot; into updatedAt. For createdAt, you could use the following logic to save to your createdAt field:&lt;br /&gt;
&lt;br /&gt;
if(&lt;br /&gt;
  isnull(CDT.createdAt),&lt;br /&gt;
  now(),&lt;br /&gt;
  CDT.createdAt&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Otherwise, you could have the same logic built into the submission button on your form. &lt;br /&gt;
&lt;br /&gt;
Personally, I don&amp;#39;t like having a lot of code on the submit button since it&amp;#39;s not always an obvious place to check. Meanwhile, looking through process history makes it very clear what&amp;#39;s happening in your process model. Thus, I would recommend the first solution.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>