gs.getProperty not working in UI script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 01:49 AM - edited ‎03-28-2025 02:09 AM
Hi
I want to get the sys_ids stored in a property. Also, tried to create glide ajax to get sys_id in UI script. None is working.
Any idea how to do it by gliderecord in ajax.
(function() {
var ids = [];
var ga = new GlideAjax('sn_csm_uni_theme.CheckUserLoggedIn');
ga.addParam('sysparm_name', 'public_catalogs');
var x;
ga.getXMLAnswer(function(response) { // Use callback function
x = response;
if (window.location.href.toString().indexOf("sc_cat_item&sys_id") > 0) {
var url = window.location.href;
url = url.replace('sc_cat_item&sys_id', x);
window.location.assign(url);
}
});
var CheckUserLoggedIn = Class.create();
CheckUserLoggedIn.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
public_catalogs: function() {
var ids = [];
var gr = new GlideRecord("sc_cat_item_user_criteria_mtom");
gr.addEncodedQuery("user_criteria.nameLIKEAny User^sc_cat_item.active=true");
gr.query();
while (gr.next()) {
ids.push(gr.sc_cat_item.sys_id.toString());
}
return ids;
},
type: 'CheckUserLoggedIn'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 04:21 AM
Glad to know that my comment helped to resolve the 1st part of error.
Did you add gs.info() and see script include is getting called?
share screenshots of both UI script and script include? they both are in which scope?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 04:33 AM
gs.info() not coming.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 04:45 AM
Hi @Rosy14 ,
Where are you checking the logs using gs.info()?
You can use gs.info("My script include" + gr.ids);
Then trigger your use case so that script include is executed.
Then search in system Log->Log. Refer below snip
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit