- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:33 PM
I am trying to achieve this requirement by script include & client script:
Script Include -
Table from which I am trying to get date value - u_test_change
Field which is having date stored in "u_test_change" table - u_effective_date
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 10:07 PM
@Priya Singh 2 2
Use this script , this is working for me :
Script Include:
var PopulateStartDateUtil = Class.create();
PopulateStartDateUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChangeDate: function() {
var userID = this.getParameter('sysparm_user_id');
var grDate = new GlideRecord('u_test_change');
grDate.addQuery('u_user', userID); // Assuming there's a reference to user
grDate.query();
if (grDate.next()) {
return grDate.getValue('u_effective_date');
}
return '';
},
type: 'PopulateStartDateUtil'
});
Catalog Client Script:
function onLoad() {
var userID = g_user.userID;
var ga = new GlideAjax('PopulateStartDateUtil');
ga.addParam('sysparm_name', 'getChangeDate');
ga.addParam('sysparm_user_id', userID);
ga.getXMLAnswer(function(response) {
var dateValue = response;
if (dateValue) {
g_form.setValue('start_date', dateValue);
}
});
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:45 PM
Hi @Priya Singh 2 2 ,
Please follow below script
Script Include:
var PopulateStartDateUtil = Class.create();
PopulateStartDateUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChangeDate: function() {
var userID = this.getParameter('sysparm_user_id');
var grDate = new GlideRecord('u_test_change');
grDate.addQuery('u_requested_for', userID);
grDate.orderByDesc('sys_created_on');
grDate.query();
if (grDate.next()) {
return grDate.getValue('u_effective_date'); // Return the value properly
}
return '';
},
type: 'PopulateStartDateUtil'
});
Client Script:
function onLoad() {
var userID = g_user.userID; // Get current user ID
var ga = new GlideAjax('PopulateStartDateUtil');
ga.addParam('sysparm_name', 'getChangeDate');
ga.addParam('sysparm_user_id', userID);
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('start_date', response);
}
});
}
Make sure u_effective_date is a valid Date/Time or Date field.
Ensure the Script Include is accessible from the client:
It must be client-callable. Confirm that Is Client Callable is checked in the Script Include definition.
Test by logging output in grDate.getValue(...) or using gs.info(...).
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Arun Manoj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:47 PM
Hi @Priya Singh 2 2
Please confirm, if both catalog date variable (start_date ) and table field (u_effective_date), have Date fields or Date and Time, please check the type of both fields and variable, if both is Date or Date and Time. Please confirm.
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 09:51 PM - edited 06-15-2025 10:16 PM
Hi,
You are doing the client script as an onLoad script. Is this intentional?
Otherwise I would assume you would want to run the script as part of a change on the form, when the input for a user selection is changed, or similar.
Does the form contain a value for user to pass to the script include at loadtime ?
It seems like the variable "userID" in the client script is undefined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 10:07 PM
@Priya Singh 2 2
Use this script , this is working for me :
Script Include:
var PopulateStartDateUtil = Class.create();
PopulateStartDateUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChangeDate: function() {
var userID = this.getParameter('sysparm_user_id');
var grDate = new GlideRecord('u_test_change');
grDate.addQuery('u_user', userID); // Assuming there's a reference to user
grDate.query();
if (grDate.next()) {
return grDate.getValue('u_effective_date');
}
return '';
},
type: 'PopulateStartDateUtil'
});
Catalog Client Script:
function onLoad() {
var userID = g_user.userID;
var ga = new GlideAjax('PopulateStartDateUtil');
ga.addParam('sysparm_name', 'getChangeDate');
ga.addParam('sysparm_user_id', userID);
ga.getXMLAnswer(function(response) {
var dateValue = response;
if (dateValue) {
g_form.setValue('start_date', dateValue);
}
});
}
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma