Add the duration variable to date and time variable and populat the end date value in string var
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:35 AM
Hi Team,
I have created variable's in catalogs
1 start date - Date and time type variable
2 required time - Duration type variable
3 End time - String type.
I need to add the duration and date and time variables. And populate the end time in string variable
I tried below script but its not working
Script inculde
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:49 AM
Hi @Community Alums ,
I've done some modification in your client script and script include, try them and see if it helps:
Script include:
var UtilsAjax = Class.create();
UtilsAjax.prototype = {
initialize: function() {
},
endtime: function() {
var selected_date = new GlideDateTime();
selected_date.setDisplayValue(this.getParameter('sysparm_Date'));
var duration = parseInt(this.getParameter('sysparm_Duration'), 10); // Assuming duration is in minutes
selected_date.addMinutes(duration);
return selected_date.getDisplayValue();
},
type: 'UtilsAjax'
};
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var duration = g_form.getValue('duration');
var start_date = g_form.getValue('start');
var ga = new GlideAjax('UtilsAjax');
ga.addParam('sysparm_name', 'endtime');
ga.addParam('sysparm_Date', start_date);
ga.addParam('sysparm_Duration', duration);
ga.getXML(CheckDateValidation);
}
function CheckDateValidation(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('end_time', answer);
}
Thanks.
Hope this helps.
If my response turns useful please mark it helpful and accept solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 04:39 AM
Thank you for help.
I am using above script . But getting null value.
Please help me on this error
Thank you
Sivananda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 05:46 AM
@HrishabhKumar Can you please help me on that