Record producer received empty records from notification

Abigail
Tera Expert

Hello,

I have a Record Producer that receives the survey number from a notification button. The button sends a URL, for example:

https://exampledev.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=84178...

This value is received by the Record Producer. I want to clarify that it only captures the survey number, not the logged-in user.

The issue I’m facing is that when I impersonate another user who does not have the ADMIN role, the Record Producer results appear empty.


I don't have any conditions set for availability, and I didn't use a client script to specify the user, so I'm not sure why this is happening.

Any idea?

Thanks



1 ACCEPTED SOLUTION

@Abigail 

is this script include getting called?

how are you passing the number?

Are you using client callable script include in GlideAjax and this is for external users i.e. snc_external role?

If yes then you need to make script include public by adding this function to it

isPublic: function(){
return true;
},

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

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Abigail 

so you have a notification which contains that URL where survey number is included in URL as parameter

when some user clicks that button? what happens? any error? share screenshots

When the record producer form loads are you getting the value from URL and setting it in some variable?

share more details

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

Hello @Ankur Bawiskar,

When someone clicks on the notification button, they are redirected to the Record Producer. The URL sends the survey number as a parameter, and the Record Producer uses this number to display the relevant values.

However, for some reason, it’s not working for users who don’t have the admin role. Any idea why this might be happening?

@Abigail 

so please share the script etc which is bringing the relevant values? how it's done? share screenshots.

Are you using client callable script include in GlideAjax and this is for external users i.e. snc_external role?

If yes then you need to make script include public by adding this function to it

isPublic: function(){
return true;
},

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

Hello @Ankur Bawiskar 

 

Here is the script include

var Get_results = Class.create();
Get_results.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    type: 'Get_results',

    getSurvetdetails: function() {
        var ticketsys;
        var ticketnum = this.getParameter('sysparm_ticket'); // Get parameter from client

        var grAAI = new GlideRecord('asmt_assessment_instance');
        grAAI.addEncodedQuery("number=" + ticketnum);
        grAAI.query();
        if (grAAI.next()) {
            ticketsys = grAAI.getValue('sys_id');
        }

        return JSON.stringify(this._getMetricResults(ticketsys)); // Return as JSON string

    },

    _getMetricResults: function(ticketsys) {
        var objres = {};

        var grAMR = new GlideRecord('asmt_metric_result');
        grAMR.addEncodedQuery("metric=56775bd387fe0e10eced43f6cebb35a3^ORmetric=0ebaacc687e6c690eced43f6cebb35c5^instance="+ticketsys);
        grAMR.query();
		var rowCount = grAMR.getRowCount();
        while (grAMR.next()) {
            if (grAMR.getValue('metric')== "56775bd387fe0e10eced43f6cebb35a3") {
                objres.res = grAMR.getValue('string_value');
            }
            if (grAMR.getValue('metric')== "0ebaacc687e6c690eced43f6cebb35c5") {
                objres.nps = grAMR.getValue('string_value');
				if(rowCount == 1)
				{
					objres.res = "";
				}
            }
            objres.surveyval = grAMR.getValue('instance');
        }

        return objres;
    },

});