gs.getProperty not working in UI script

Rosy14
Tera Guru

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'
});
12 REPLIES 12

Hi @Rosy14 ,

 

Then please debug. Check if there is a value in your array ids using gs.info(ids). 

Similarly debug the return value. 

 

If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Rohit

 

Rosy14
Tera Guru

I am getting below error msg

Error Message

Read operation on table 'sc_cat_item_user_criteria_mtom' from scope 'Customer Service Management Unified Theme' was denied. The application 'Customer Service Management Unified Theme' must declare a cross scope access privilege. Please contact the application author to update their privilege requests.
 
Though I hace checked allow config on the sc_cat_item_user_criteria_mtom table

@Rosy14 

it's a cross scope access issue.

try to add this cross scope and then see

Ensure you are in "Customer Service Management Unified Theme" scope and then create new record like that

AnkurBawiskar_0-1743157455809.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Rosy14 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi that error is sorted but the value is not coming from Script include