- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 04:43 AM
HI All
I have a requirement in change module. There are two fields in change request and CTASK table that is "Planned start date" and "Planned end date". So the requirement is whenever any CTASK created, "Planned start date" and "Planned end date" should be auto fill from the change request form. For this I have written two onLoad client script and two script include. Issue is whenever I am opening a new Ctask or existing Ctask all the time it is showing a warning message "Task end date should be in the change window" and end date field is become blank. Can some one please help me where my script is going wrong or what should I do to correct script so that it will work fine. Below is the code.
Thanks in advanced
Script include: populatesupportGroup3
var populatesupportGroup3 = Class.create();
populatesupportGroup3.prototype = Object.extendsObject(AbstractAjaxProcessor, {
groupPopulation: function(){
var sysID = this.getParameter('sysparm_cr_sysid');
var crGrp = new GlideRecord('change_request');
crGrp.get(sysID);
return crGrp.end_date;
},
type: 'populatesupportGroup3'
});
Client script: Copy Planned end date from Chg request
function onLoad() {
//Type appropriate comment here, and begin script below
var group = new GlideAjax('populatesupportGroup3');
group.addParam('sysparm_name', 'groupPopulation');
group.addParam('sysparm_cr_sysid', g_form.getValue('change_request'));
group.getXML(result);
function result(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('planned_end_date', answer);
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 11:50 PM - edited 05-03-2023 11:51 PM
So the 5 hour difference is causing the issue? That could be a localization issue as the time value held in the field is on another timezone and you're setting it to the field in your timezone.
In your script include try changing it like this:
var populatesupportGroup3 = Class.create();
populatesupportGroup3.prototype = Object.extendsObject(AbstractAjaxProcessor, {
groupPopulation: function(){
var sysID = this.getParameter('sysparm_cr_sysid');
var crGrp = new GlideRecord('change_request');
crGrp.get(sysID);
var gd = new GlideDateTime();
gd.setValue(crGrp.end_date);
return gd.getDisplayValue();
},
type: 'populatesupportGroup3'
});
Now you'd basically return the DisplayValue of the date field which should now be +-5hours different from the previous value.
Edit:
Changed GlideDate to GlideDateTime
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 11:41 PM
Hi
Yes you are right there is client scrit which validate the date and time. However that is not causing the issue. I observed closely and found in the change_task form planned start date and planned end date time is not populating correctly. Around 5hr hour difference is there. And becasue of that I am facing the issue.
In the change request planned start date is :2023-05-18 02:58:27
Planned end date is: 2023-05-19 02:58:32
However when I am opening the change task form this time is not getting populated correctly. See the screen shot.
Planned start date: 2023-05-18 07:58:27
Planned end date: 2023-05-19 07:58:32
Can someone please how to correct the 5hr difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 11:50 PM - edited 05-03-2023 11:51 PM
So the 5 hour difference is causing the issue? That could be a localization issue as the time value held in the field is on another timezone and you're setting it to the field in your timezone.
In your script include try changing it like this:
var populatesupportGroup3 = Class.create();
populatesupportGroup3.prototype = Object.extendsObject(AbstractAjaxProcessor, {
groupPopulation: function(){
var sysID = this.getParameter('sysparm_cr_sysid');
var crGrp = new GlideRecord('change_request');
crGrp.get(sysID);
var gd = new GlideDateTime();
gd.setValue(crGrp.end_date);
return gd.getDisplayValue();
},
type: 'populatesupportGroup3'
});
Now you'd basically return the DisplayValue of the date field which should now be +-5hours different from the previous value.
Edit:
Changed GlideDate to GlideDateTime