<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to display current date in the form? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38459#M16179</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/76783"&gt;@EddieMay&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;new Date() will store current date into variable "today".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;And I am assigning it to field called "myDate".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I need to make sure new Date() should not run everytime I open the form and store new date into variable.&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 May 2020 14:18:33 GMT</pubDate>
    <dc:creator>alfresco1576</dc:creator>
    <dc:date>2020-05-18T14:18:33Z</dc:date>
    <item>
      <title>How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38456#M16176</link>
      <description>&lt;P&gt;I want to display the current date in the form. So whenever you create new process instance, it should fetch the current date and display in the form.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Issue:&lt;/STRONG&gt; I am able to get and display current date but that code is running everytime I open the form and display that date. (If I create new process instance today, today's date is displaying in the form but if I open form tomorrow then it will display tomorrow date)&lt;/P&gt;&lt;P&gt;How can I make sure that it should only display the date when the form is created for particular process instance?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code to get current date:&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var myDate = scope.findFormFieldWithId(scope.allFormFields, 'myDate');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var today = new Date();&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var dd = String(today.getDate()).padStart(2, '0');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var mm = String(today.getMonth() + 1).padStart(2, '0');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;var yyyy = today.getFullYear();&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;today = mm + '/' + dd + '/' + yyyy;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;myDate.value = today;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then I am using "&lt;STRONG&gt;Display text&lt;/STRONG&gt;" form field to display '&lt;STRONG&gt;myDate&lt;/STRONG&gt;'&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2020 14:25:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38456#M16176</guid>
      <dc:creator>alfresco1576</dc:creator>
      <dc:date>2020-04-16T14:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38457#M16177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/77322"&gt;@alfresco1576&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;Aren't you just assigning &lt;EM&gt;myDate&lt;/EM&gt; to be &lt;EM&gt;today&lt;/EM&gt;?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2020 13:55:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38457#M16177</guid>
      <dc:creator>EddieMay</dc:creator>
      <dc:date>2020-04-20T13:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38458#M16178</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Where you are writing above code?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2020 04:14:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38458#M16178</guid>
      <dc:creator>sp2</dc:creator>
      <dc:date>2020-04-24T04:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38459#M16179</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/76783"&gt;@EddieMay&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;new Date() will store current date into variable "today".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;And I am assigning it to field called "myDate".&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I need to make sure new Date() should not run everytime I open the form and store new date into variable.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 14:18:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38459#M16179</guid>
      <dc:creator>alfresco1576</dc:creator>
      <dc:date>2020-05-18T14:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38460#M16180</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/36939"&gt;@sanjaybandhniya&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing the code inside JavaScript in the form.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 14:20:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38460#M16180</guid>
      <dc:creator>alfresco1576</dc:creator>
      <dc:date>2020-05-18T14:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to display current date in the form?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38461#M16181</link>
      <description>&lt;P&gt;In your code, place condition and check that your field has a value or not and base on that write your code.&lt;/P&gt;&lt;PRE&gt;var myDate = scope.findFormFieldWithId(scope.allFormFields, 'myDate');
if(myDate.value==null){
	var today = new Date();
	var dd = String(today.getDate()).padStart(2, '0');
	var mm = String(today.getMonth() + 1).padStart(2, '0');
	var yyyy = today.getFullYear();
	today = mm + '/' + dd + '/' + yyyy;
	myDate.value = today;
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 May 2020 04:01:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-display-current-date-in-the-form/m-p/38461#M16181</guid>
      <dc:creator>sp2</dc:creator>
      <dc:date>2020-05-19T04:01:26Z</dc:date>
    </item>
  </channel>
</rss>

