- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:42 AM
Continuing to my previous question,
I have a one date/time type variable in my catalog item which is displaying me date/time as per my catalog client script from which i have called a script include.
Now, its populating value like - 2022-08-02 04:13:17
I want this above in different format like- 2022-08-02T04:13:17+0000 (where T and +0000 remain same every time i'm getting this value)
please help me for this one and tell where i need to make changes
My script Include:
var AutoPopulateDate = Class.create();
AutoPopulateDate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDate: function() {
var daysrequired = this.getParameter('sysparm_days_required');
var currentDate = new GlideDateTime(gs.now());
currentDate.addMonths(daysrequired);
return currentDate;
},
type: 'AutoPopulateDate'
});
My catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('Days Required change');
var ga = new GlideAjax('AutoPopulateDate');
ga.addParam('sysparm_name', 'getDate');
ga.addParam('sysparm_days_required', newValue);
ga.getXML(CallBackFunction);
function CallBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('return date '+answer);
g_form.setValue('date',answer);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:46 AM
You can try below
var result = answer .replace(" ", "T") + "+0000";
g_form.setValue('date',result);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:46 AM
You can try below
var result = answer .replace(" ", "T") + "+0000";
g_form.setValue('date',result);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:52 AM
yes,it's working, thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 04:59 AM
Kindly mark my response as correct and helpful so that other users can benefit from this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2022 05:14 AM
Hey, but i'm not getting time value and its always populating 00:00:00 after changing my catalog client script
in short, i want my date/time type variable to display as
2022-10-02T05:43:19+0000
But it's displaying always like
2022-10-02T00:00:00+0000
please help in this