CMDB Query Builder - how to use query result in a shared report

Marc Halleux
Mega Expert

Hi,

I got the request from a user to create a complex report using relationship between CI in the CMDB.

I decided to use the CMDB Query Builder and was able to generate the expected result. then i followed the following doc page to create a report out of it - https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/product/configuration-management....

I shared that report with the itil user who requested it. But when the user try to access that report, the result is empty.

Obviously this ITIL user has the role - cmdb_query_builder_read and cmdb_query_builder.

Is this the right way to generate/share such a report?

BR

Marcus

 

1 ACCEPTED SOLUTION

This is still an issue when sharing reports to users. Creating a query and having a report that is created by the user and can view isn't the problem. The problem is when I want to share the report to another user or users, they cannot see the data within the report, but can view and open the report. The user has itil role and confirmed cmdb_query_builder and cmdb_query_read roles.

Looking at the read ACL for the table cmdb_qb_result_base indicates that only the user that created the query can view the results in the report. Modifying this script allowed other users to view the data and the sharing of the report was controlled by the report module instead. 

find_real_file.png

After following the KB mentioned above and the docs pages on sharing a report, the user was still only able to view the report but no data. The documentation does not indicate that the data is only visible to the original creator. As the CMDB is being leverage more, it has been increasingly popular to create more complex relational type queries and report on them. It is very common for a report to be shared with other users.

I have modified the script above in the read ACL of cmdb_qb_result_base table so that other users can view the data of the report.

View solution in original post

12 REPLIES 12

Navin Sharma
ServiceNow Employee
ServiceNow Employee

Have you tried below - using the Query Builder "Create Report" functionality.  This was available from Paris, onwards. 

 

find_real_file.png

find_real_file.png

I have tried this but still users were unable to view the report.

Robert, the same thing happened to me until I re-read the Knowledge article.  The correct edit is this:

answer = true;
    
// (current.sys_created_by == gs.getUserName());
// if (answer) {
//     var fields = current.getFields();
//     for (var i = 0; i < fields.size() && answer; i++) {
//         var fieldName = fields.get(i).getName();
//         if (fieldName.startsWith("u_rel_")) {
//             var val = current.getValue(fieldName);
//             var rel = new GlideRecord('cmdb_rel_ci');
//             rel.get(val);
//             var canRead = rel.canRead();
//             answer = canRead;
//         }
//     }
// }

Originally I had changed answer = canRead to answer = true deeper in the if statement. Then, after a re-read of the KB, it dawned on me that it was supposed to be the top most level with the rest commented out.

(referenced from Jha above: )

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0795985