Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How can we check the record is met with the conditions of a table using sys_id.

Allu Gopal1
Giga Guru

Hi All,

I am having a requirement that when we pass the sys_id of a particular record like from this table "sysapproval_approver", it should fetch the sys_id of particular record in this table "sn_hr_sp_todos_config" only when condition met.

I tried code like this:

 data.sysIdURL = $sp.getParameter("sys_id");
    data.canRead = false;
    data.tableName = $sp.getParameter("sysparm_tableName");

    ///for to-do sys_id///////
    var scriptGR = new GlideRecord("sn_hr_sp_todos_config");
    scriptGR.addActiveQuery();
    scriptGR.addQuery('table', data.tableName);
    scriptGR.query();

    while (scriptGR.next()) {
        var encodedQueryString = scriptGR.getValue("condition");
        if (GlideFilter.checkRecord(data.sysId, encodedQueryString)) {
            //gs.addInfoMessage(encodedQueryString.toString());
            gs.addInfoMessage(scriptGR.getUniqueValue());
        }

    }

But it is not working, It is throwing Null Pointer exception. Please help me on working this with correct answer.

Thanks and Regards,

Allu Gopal.

2 REPLIES 2

Allu Gopal1
Giga Guru

HI @Ankur Bawiskar  Please help me on this if you know.

Thanks and Regards,

Allu Gopal.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

syntax is wrong

GlideFilter - Scoped

data.sysIdURL = $sp.getParameter("sys_id");
data.canRead = false;
data.tableName = $sp.getParameter("sysparm_tableName");

///for to-do sys_id///////
var scriptGR = new GlideRecord("sn_hr_sp_todos_config");
scriptGR.addActiveQuery();
scriptGR.addQuery('table', data.tableName);
scriptGR.query();
while (scriptGR.next()) {
    var encodedQueryString = scriptGR.getValue("condition");
    if (GlideFilter.checkRecord(scriptGR,encodedQueryString)) {
        //gs.addInfoMessage(encodedQueryString.toString());
        gs.addInfoMessage(scriptGR.getUniqueValue());
    }

}

Regards
Ankur

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