<?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>question Re: Past Date on Date field should thrown an error near field in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/2920668#M1111208</link>
    <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;g_form.showFieldMsg(&lt;/SPAN&gt;&lt;SPAN&gt;"u_date_field"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'You can not select a Past Date'&lt;/SPAN&gt;&lt;SPAN&gt;);&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;we need to mention the field on which we need to show field message.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 07 May 2024 05:06:12 GMT</pubDate>
    <dc:creator>keshavgowda</dc:creator>
    <dc:date>2024-05-07T05:06:12Z</dc:date>
    <item>
      <title>Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449633#M106559</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My requriement is I have only 1 date field whenever i select past date from today it should show field error message. I tried using UI policy but only for 1st time it's working,if i keep on checking again and again the error is not occuring.&lt;/P&gt;
&lt;P&gt;Please somebody help me what is the best approach for this?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Gayathri&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 12:22:21 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449633#M106559</guid>
      <dc:creator>Gayathri5</dc:creator>
      <dc:date>2022-02-03T12:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449634#M106560</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Gayathri,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use this script in UI policy&lt;/P&gt;
&lt;P&gt;condition :&lt;/P&gt;
&lt;P&gt;yourdateFieldname before today.&lt;/P&gt;
&lt;P&gt;function onCondition() {&lt;BR /&gt; g_form.clearValue('u_date');&lt;/P&gt;
&lt;P&gt;g_form.showErrorBox("u_date","Please select future date and time",true);&lt;/P&gt;
&lt;P&gt;//or u can put following line.&lt;/P&gt;
&lt;P&gt;//alert("Please select future date and time");&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please mark correct/helpful based on impact.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Aniket Sawant&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 12:47:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449634#M106560</guid>
      <dc:creator>Aniket Sawant2</dc:creator>
      <dc:date>2022-02-03T12:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449635#M106561</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You can use onChange client script on the required field and write the code to check if the user is entering the past date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please mark correct/helpful based on impact.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Bharath kumar&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 13:00:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449635#M106561</guid>
      <dc:creator>Bharath kumar6</dc:creator>
      <dc:date>2022-02-03T13:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449636#M106562</link>
      <description>&lt;P&gt;I tried this but i was facing some issue so through client script we can achieve.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can u achieve the same using client script?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Feb 2022 13:06:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449636#M106562</guid>
      <dc:creator>Gayathri5</dc:creator>
      <dc:date>2022-02-03T13:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449637#M106563</link>
      <description>&lt;P&gt;Hi Gayathri,&lt;/P&gt;
&lt;P&gt;Create onChange Client Script on Field u want to change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var currentDate = new Date(); //Current Date
    var selectedDate = new Date(g_form.getValue('u_date_field')); //Date field value

    if (currentDate.getTime() &amp;gt;= selectedDate.getTime()) {
        //Past Date on Date field should thrown an error near field
        g_form.showFieldMsg('You can not select a Past Date');
        return false;
    }

}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Mar 2022 08:27:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449637#M106563</guid>
      <dc:creator>Shakeel Shaik</dc:creator>
      <dc:date>2022-03-03T08:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449638#M106564</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try Below...It works.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Client Script :&amp;nbsp;&lt;/STRONG&gt;Onchange Client Script&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var udt = newValue;
    var ga = new GlideAjax("GetCurrentDateAndTime");
    ga.addParam('sysparm_name', 'GetDate');
    ga.addParam('sysparm_get_date', udt);
    ga.getXML(HelloWorldParse);

    function HelloWorldParse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer == '5') {
            g_form.setValue('date_field_name', "");
            return false;
    }
}
}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Script Include&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;var GetCurrentDateAndTime = Class.create();
GetCurrentDateAndTime.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    GetDate: function() {
        var getNum = this.getParameter('sysparm_get_date');
        var nd = new GlideDateTime();
        if (getNum &amp;gt; nd) {
            return 5;
    },
    type: 'GetCurrentDateAndTime'
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 08:26:42 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449638#M106564</guid>
      <dc:creator>Raghu Ram Y</dc:creator>
      <dc:date>2022-03-07T08:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449639#M106565</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Gayathri&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If my above response is helpful, then Please mark as Correct&amp;nbsp;&lt;STRONG&gt;Answer/Helpful.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any queries, let us know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 19:16:24 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/1449639#M106565</guid>
      <dc:creator>Shakeel Shaik</dc:creator>
      <dc:date>2022-03-07T19:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Past Date on Date field should thrown an error near field</title>
      <link>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/2920668#M1111208</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;g_form.showFieldMsg(&lt;/SPAN&gt;&lt;SPAN&gt;"u_date_field"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'You can not select a Past Date'&lt;/SPAN&gt;&lt;SPAN&gt;);&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;we need to mention the field on which we need to show field message.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 07 May 2024 05:06:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/past-date-on-date-field-should-thrown-an-error-near-field/m-p/2920668#M1111208</guid>
      <dc:creator>keshavgowda</dc:creator>
      <dc:date>2024-05-07T05:06:12Z</dc:date>
    </item>
  </channel>
</rss>

