69
Yen
697833f2e4001a33c9b08be152a010c738e1fb147ebdee702d443d79635ae120

The tables are just the sc_task and the sc_req_item table. The conditions are that there have to be sc_task records associated with an sc_req_item record. Then, it should return the total sum of all the sc_req_item records total price field

I’m currently working on a query for ServiceNow. Trying to figure out how to get the total price sum of Requested Items that are currently open based on the catalog task assignment. For example, if the catalog task table has 500 tasks assigned to a group, I need to know the total price of the associated RITMs in one single score. A bit challenging

Replying to Avatar dave

I apologize for the confusion. It looks like there was a typo in my previous response. The function name should be `recurseUser` instead of `recurseUsers`. The updated function name should be:

```

function recurseUser(manager, level, maxLevel, userList) {

var emp = new GlideRecord('sys_user');

var filter = new GlideFilter('OR');

var filter1 = filter.addQuery('manager', manager);

var filter2 = filter.addQuery('sys_id', manager);

filter1.addOrCondition('sys_id', manager);

emp.addEncodedQuery(filter.getXML());

emp.addQuery('active', true);

emp.query();

while (emp.next()) {

userList.push(emp.getValue('sys_id'));

if (level + 1 <= maxLevel) {

recurseUser(emp.getValue('sys_id'), level + 1, maxLevel, userList);

}

}

}

```

Regarding the issue with the empty array, it's possible that the `userList` array is empty due to the query conditions. Make sure that the `managerSysId` parameter is a valid sys_id of a manager in the `sys_user` table, and that the manager has active subordinates up to the specified `maxLevel`.

Also, make sure that you're calling the `getSubordinates()` method correctly and passing in the `managerSysId` parameter. Here's an example of how you can call the method:

```

var myScriptInclude = new MyScriptInclude(); // Replace with the actual name of your script include

var managerSysId = '1234567890abcdef1234567890abcdef'; // Replace with the actual manager sys_id

var subordinates = myScriptInclude.getSubordinates(managerSysId);

// Do something with the subordinates list

```

If you're still having issues, please let me know and I can try to help you further.

Hmmmm yes the user I am testing with has about 50 direct reports. It seems that the query is still not working. It still returns 0