Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Not able to call the script include in the arguments from "All" module in incident

prasannasun
Tera Contributor

Hi Everyone,

 

I have created a Script Include, and with this Script Include I want to retrieve incidents that meet the following conditions:

  • Incidents opened by me

  • Incidents where the caller_id is me

  • Incidents where I am part of the assignment group

I do not want to use filter conditions in the module because I am testing a scenario where I need to pull data from different places. Therefore, I want to use a Script Include and call it in the "All" module related to Incident through the Arguments field.

When I test the Script Include in Scripts - Background, it returns the expected values. However, when I click on the All module, it does not return the results.

I tried calling the Script Include using the following approaches in the module arguments:

  • sysparm_query=javascript:new IncidentVisibilityUtil().getMyIncidents()

  • javascript:new IncidentVisibilityUtil().getMyIncidents()

But neither of these worked.

Could you please help me understand the correct way to call this Script Include from the module arguments? Also, please let me know if I am missing anything in my configuration.

 

var IncidentVisibilityUtil = Class.create();
IncidentVisibilityUtil.prototype = {

    getMyIncidents: function() {

        var userId = gs.getUserID();
        var groups = [];

        var grMember = new GlideRecord('sys_user_grmember');
        grMember.addQuery('user', userId);
        grMember.query();

        while (grMember.next()) {
            groups.push(grMember.group.toString());
        }

        var query = 'opened_by=' + userId + '^ORcaller_id=' + userId;

        if (groups.length > 0) {
            query += '^ORassignment_groupIN' + groups.join(',');
        }

        return query;
    },

    type: 'IncidentVisibilityUtil'
};
0 REPLIES 0