- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 01:59 AM
i want to validate date is past or not if past want to display error msg using g_form.showfieldmessage
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 02:26 AM
Hi
You can check using Client Script On Change calling a script include where u can check the date with current date
Example Code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('DateandTIme');
ga.addParam('sysparm_name', 'getcurrentdate');
ga.addParam('sysparm_Publised', newValue);
ga.getXML(UpdatePublished);
}
function UpdatePublished(response, newValue){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer){
// g_form_show field msg
g_form.clearValue('published');
return;
}
}
Script include :
var DateandTIme = Class.create();
DateandTIme.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getcurrentdate : function(){
var publisheddate = this.getParameter('sysparm_Publised');
if(publisheddate < gs.nowDateTime()){
return true;
}
else
return false;
},
type: 'DateandTIme'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 02:23 AM
Actually im getting some error like on script error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 02:26 AM
Hi
You can check using Client Script On Change calling a script include where u can check the date with current date
Example Code:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('DateandTIme');
ga.addParam('sysparm_name', 'getcurrentdate');
ga.addParam('sysparm_Publised', newValue);
ga.getXML(UpdatePublished);
}
function UpdatePublished(response, newValue){
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer){
// g_form_show field msg
g_form.clearValue('published');
return;
}
}
Script include :
var DateandTIme = Class.create();
DateandTIme.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getcurrentdate : function(){
var publisheddate = this.getParameter('sysparm_Publised');
if(publisheddate < gs.nowDateTime()){
return true;
}
else
return false;
},
type: 'DateandTIme'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 02:53 AM
Thank U its working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2017 04:55 AM
You could use a UI Policy for this - there's a "on or before today" condition that can be placed against date fields, rather than script it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2017 09:37 PM
Thank you David