- 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 10:20 PM
why not use auto populate feature/logic and then no scripting is required?
Auto-populate a variable based on a reference type variable (Utah)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2025 09:27 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 09:17 AM
Thank you for marking my response as helpful.
I believe I also answered your question with a better alternative.
As per new community feature you can mark multiple responses as correct.
If my response helped please mark it correct as well so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader