Servicenow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 06:09 AM
Can anyone help me with this code , Below i attached 2 files .So if i select the date for example from 02-01-2024(effective date) to 12-01-2024(effective date) so in the end point its triggering with same year but with diff date and month , can anyone look at the script and files and guide where i went wrong?
Onchange Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('iamServiceAccountOnboardingUtils'); //scriptinclude name
ga.addParam('sysparm_name', 'calculateEndDate'); //function name
ga.addParam('sysparm_effective_date', newValue);
ga.getXML(answerCallback); // Define the callback function
}
function answerCallback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
// Set the calculated end date in the end date field
g_form.setValue('end_date', answer);
}
}
Script Include
Script Include
var iamServiceAccountOnboardingUtils = Class.create();
iamServiceAccountOnboardingUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
calculateEndDate: function() {
var effectiveDate = this.getParameter('sysparm_effective_date');
var endDate = new GlideDateTime(effectiveDate);
endDate.getDate().getByFormat("dd-MM-yyyy");
endDate.addYearsLocalTime(1);
return endDate.getValue();
},
type: 'iamServiceAccountOnboardingUtils'
});
10 REPLIES 10

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 08:31 AM
What is the last state of the issue?