Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
An onChange client script that calls the script includes one that adds the specified number of business days to the planned start date and autopopulates the planned end date based on the type.
For the client callable script include refer to the README file in the Add Business Days Script include folder. Link: [Add Business Days Script Include](/Server-Side%20Components/Script%20Includes/Add%20Business%20Days/README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//Client script
//Table: Change Request
//UI Type: All
//Type: onChange
//Field: Planned Start Date
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var daysToAdd;
if(g_form.getValue('type') =='standard' || g_form.getValue('type') =='normal')
daysToAdd = 3;
else if(g_form.getValue('type') =='emergency')
daysToAdd = 1;
var ga = new GlideAjax("addBusinessDays"); //Calling the add business days script include, which is in the Server-Side Components/Script Includes/Add Business Days/addBusinessDays.js
ga.addParam('sysparm_name', 'addDays');
ga.addParam('sysparm_days', daysToAdd);
ga.addParam('sysparm_date', newValue);
ga.getXML(processResponse);

function processResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer").toString();
g_form.setValue('end_date', answer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The client callable script includes adds number of business days using the OOB 8-5 weekdays, excluding holidays, schedule
The script includes the sys_id of the OOB schedule, calculates the number of business days, and returns the date.
For the onChange client script, refer to the README file in the Auto-POpulate Planned End Date client script folder. Link: [Auto-Populate Planned End Date Client Script](/Client-Side%20Components/Client%20Scripts/Auto-Populate%20Planned%20End%20Date/README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Takes the number of days as a parameter, and the start date
//Name: addBusinessDays
//Client Callable: checked
var addBusinessDays = Class.create();
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828');
addBusinessDays.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

addDays: function() {
var days = parseInt(this.getParameter("sysparm_days"));
var startDate = new GlideDateTime(this.getParameter("sysparm_date").toString());
var sd = startDate;
startDate = startDate.getDate();
var time = sd.getTime().getByFormat('HH:mm:ss');
var dur = new GlideDuration(60 * 60 * 1000 * (days * 9));
schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); //sys_id of OOB schedule 8-5 weekdays excluding holidays
var end = schedule.add(startDate, dur);
var endDate = end.getDate().getByFormat("MM/dd/yyyy");
var endDateTime = endDate + ' ' + time;
return endDateTime.toString();
},
type: 'addBusinessDays'
});
Loading