How to filter Service Offerings based on Services selected from Record Producer ( Service Portal)

Vijayr119
Tera Contributor

How to filter Service Offerings based on Services selected from Record Producer ( Service Portal)

Both Service and Service Offering variables are referencing to cmdb_ci_services tabel

find_real_file.pngfind_real_file.png

1 ACCEPTED SOLUTION

Hi,

So it means the ref qualifier works with hard-coded value of service sysId

Since you want to filter records you need not use script include; this should ideally work

Is the variable name business_service correct?

javascript: 'parent=' + current.variables.business_service.toString();

Regards
Ankur

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

View solution in original post

18 REPLIES 18

Still not filtering.. displaying empty from service offerings list

 

find_real_file.png

 

find_real_file.png

 

Am I doing any wrong here? This is the Offerings table.

 

Note: I'm doing this work for a Record Producer.. is that because of that? or any cross scope application issue?

 

find_real_file.png

Nope it should not be. Can you make your Script Include accessible to All Scopes. 

Also can you put a log and see if the Script Include is getting executed and what it is returning as shown below and let me know what values are you getting there:

I have modified the script Include as parameter name was missing in my initial script so use below

function getOfferings(service) {
gs.info('SI getting called' + service);
    var arr = [];
    
    var gr = new GlideRecord('offering Table Name Here');
    gr.addQuery('parent field name', service);
    gr.query();
    while (gr.next()) {
        arr.push(gr.sys_id.toString());
    }
gs.info('Value returned is ' + arr);
    return 'sys_idIN' + arr.toString();
}

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

its returning nothing from logs:

 

find_real_file.png

Can you show me your Script Include Screenshot which you have written. Also can you update it as below and check again:

Script Include:

Not a Client Callable Script Include, Name of Script Include is "getOffering"

var getOffering = Class.create();
getOffering.prototype = {
    initialize: function() {},

    getServiceoffering: function(service) {
        var arr = [];

        var gr = new GlideRecord('offering Table Name Here');
        gr.addQuery('parent field name', service);
        gr.query();
        while (gr.next()) {
            arr.push(gr.sys_id.toString());
        }
        gs.info('Value returned is ' + arr);
        return 'sys_idIN' + arr.toString();
    },

    type: 'getOffering'
};

 

Reference Qualifier to be updated as below:

javascript:'sys_idIN' + new getOfferings().getServiceoffering(current.variables.VariablName);// Replace Variable Name with your Service Variable

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

ideally no need of script include

try for some hard-coded values and check if it shows only those records

javascript: 'parent=' + 'businessServiceSysId';

Regards
Ankur

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