Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2019 11:16 AM
Hi,
I want to add dates to a date/time field in catalog item. Below is the code I am using but it is not working.
Client Script :-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var daysToAdd;
if(g_form.getValue('u_itauditrequest_request_category') == "Expedited")
{
daysToAdd = 27*3600;
}
else if(g_form.getValue('u_itauditrequest_request_category') == "Standard")
{
daysToAdd = 45*3600;
}
else if(g_form.getValue('u_itauditrequest_request_category') == "Aggregated/Bulk")
{
daysToAdd = 90*3600;
}
var ga=new GlideAjax("VEN_addDaystoDate");
ga.addParam('sysparm_name', 'addDaystoDate');
ga.addParam("sysparm_daysToAdd","daysToAdd");
//ga.addParam("sysparm_startDate","startDate");
//alert(daysToAdd);
ga.getXML(duedate);
function duedate(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
g_form.setValue("due_date", answer);
}
Script Include :-
var VEN_addDaystoDate = Class.create();
VEN_addDaystoDate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
addDaystoDate:function(){
gs.include('DurationCalculator');
this.executeSample();
//var startDate=gs.nowDateTime();
executeSample:function()
{
var daysToAdd=this.getParameter('sysparm_daysToAdd');
gs.log("*** daysToAdd" +daysToAdd);
var dc = new DurationCalculator();
//this.addSchedule(dc);
var initialDate = new GlideDateTime(gs.nowDateTime());
dc.setStartDateTime(initialDate);
if(!dc.calcDuration(daysToAdd))
{
gs.log("*** Error calculating duration");
return;
}
return dc.getEndDateTime();
}
},
/*addSchedule:function(durationCalculator){
var scheduleName = "8-5 weekdays excluding US holidays";
var grSched = new GlideRecord('cmn_schedule');
grSched.addQuery('name', scheduleName);
grSched.query();
if(!grSched.next())
{
gs.log('*** Could not find schedule "'+ scheduleName +'"');
return;
}
durationCalculator.setSchedule(grSched.getUniqueValue(),"GMT");
},*/
type: 'VEN_addDaystoDate'
});
Solved! Go to Solution.
1 ACCEPTED SOLUTION

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2019 11:47 AM
HI,
Change
ga.addParam("sysparm_daysToAdd","daysToAdd");
to
ga.addParam("sysparm_daysToAdd",daysToAdd);
Thanks,
Ashutosh
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2019 11:47 AM
HI,
Change
ga.addParam("sysparm_daysToAdd","daysToAdd");
to
ga.addParam("sysparm_daysToAdd",daysToAdd);
Thanks,
Ashutosh
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2019 05:29 AM
It worked, thanks a lot !!! in identifying that.