- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 02:18 AM
Hi @Karter83,
First of all, I wouldn't recommend creating a custom table for this. There is a limit on the number of custom tables you can create and most of the information in your custom table seems like it should be already available in the User [sys_user] table. Instead, I would recommend a few different approaches:
- Create Group records per 'condition'. i.e. Create a group called 'Team Lead Cost Center XYZ' and add the appropriate members to the group
- Use Decision Table
- Store the necessary information in the User record
Anyway, I will provide some feedback of your script.
//var requesterCostCenter = gs.getUser().getCompanyRecord().getValue('cost_center'); //not sure where you got this code, but there is no 'getCompanyRecord' function in GlideUser object - https://developer.servicenow.com/dev.do#!/reference/api/washingtondc/server_legacy/GUserAPI#GUser-getID
var currentUser = new GlideRecord('sys_user');
currentUser.get( gs.getUserID());
var requesterCostCenter = currentUser.getValue('cost_center');
var approvalMatrixGr = new GlideRecord('approval_matrix'); //Are you sure this is the right name? If it's a custom table, normally the name is prepended with 'u_'
approvalMatrixGr.addQuery('approval_role', 'Team Lead'); //Also, are you sure it's the right column name? If it's a custom column, normally it's prefixed with 'u_'
approvalMatrixGr.addQuery('cost_center_id', requesterCostCenter); //Also, are you sure it's the right column name? If it's a custom column, normally it's prefixed with 'u_'
approvalMatrixGr.query();
var approvers = [];
while (approvalMatrixGr.next()) {
approvers.push(approvalMatrixGr.name.toString());
}
//approvers;
return approvers;
Is the 'Name' column in the custom table referencing the user table?
If so, you should change the reference list variable to reference the User [sys_user] table and use the reference qualifier there. Also, note that you don't have to use AJAX, and invoking the script include should be in the following format: javascript: 'sys_idIN' + new AORApprovalMatrix1().getApproverList();
That's a mouthful, best of luck. Cheers