Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
afd4406
Create Code.js
sivamuruganandam-coder Oct 5, 2025
99672a8
Create README.md
sivamuruganandam-coder Oct 5, 2025
319fcbc
Add Business rule: Add or remove tag to the ticket
sivamuruganandam-coder Oct 5, 2025
00cf6c0
Rename code.js to code.js
sivamuruganandam-coder Oct 5, 2025
b4694ab
Rename README.md to README.md
sivamuruganandam-coder Oct 5, 2025
4f0b6e5
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 5, 2025
bcba22d
Adding new UI Action: Generate PDF
sivamuruganandam-coder Oct 5, 2025
72c0986
Adding new UI Action: Generate PDF
sivamuruganandam-coder Oct 5, 2025
5d9c06b
Adding new Background script: Bulk Update of Fulfillment Group Refere…
sivamuruganandam-coder Oct 5, 2025
6f12dbd
Adding new Background script: Bulk Update of Fulfillment Group Refere…
sivamuruganandam-coder Oct 5, 2025
eec21a3
Delete Server-Side Components/Background Scripts/Bulk Update of Fulfi…
sivamuruganandam-coder Oct 5, 2025
835f9de
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 5, 2025
c0c1d1e
Update Script.js
sivamuruganandam-coder Oct 5, 2025
d3310f4
Update README.md
sivamuruganandam-coder Oct 5, 2025
ece6aea
Update README.md
sivamuruganandam-coder Oct 5, 2025
409fd7d
Delete Client-Side Components/UI Actions/Generate PDF directory
sivamuruganandam-coder Oct 5, 2025
1bb5d45
Create script.js
sivamuruganandam-coder Oct 5, 2025
843ff9a
Create README.md
sivamuruganandam-coder Oct 5, 2025
295a70f
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 5, 2025
1071238
Create script.js
sivamuruganandam-coder Oct 5, 2025
9a9619b
Create README.md
sivamuruganandam-coder Oct 5, 2025
944368e
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 5, 2025
a3622f0
Delete Server-Side Components/Script Includes/Calculate Due date usin…
sivamuruganandam-coder Oct 5, 2025
9cc1867
Create README.md
sivamuruganandam-coder Oct 5, 2025
5a50f65
Add files via upload
sivamuruganandam-coder Oct 5, 2025
a21e5fd
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 7, 2025
0fd0286
Update script.js
sivamuruganandam-coder Oct 7, 2025
f5b4e84
Update README.md
sivamuruganandam-coder Oct 7, 2025
4700422
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 7, 2025
fe6234a
Merge branch 'ServiceNowDevProgram:main' into main
sivamuruganandam-coder Oct 7, 2025
a682e1e
Create README.md
sivamuruganandam-coder Oct 7, 2025
991a0f9
Update README.md
sivamuruganandam-coder Oct 7, 2025
de09c5b
Create ui_action_script.js
sivamuruganandam-coder Oct 7, 2025
6b55cff
Create ui_page.html
sivamuruganandam-coder Oct 7, 2025
02fc026
Create ui_page_client_script.js
sivamuruganandam-coder Oct 7, 2025
4a10aec
Create ui_page_processing_script.js
sivamuruganandam-coder Oct 7, 2025
590cdf4
Update README.md
sivamuruganandam-coder Oct 7, 2025
63f79cc
Add files via upload
sivamuruganandam-coder Oct 7, 2025
237fbc5
Updated the table name ui_page_processing_script.js
sivamuruganandam-coder Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**Usecase:**
Currenlty there's no OOB feature to share the all the reports from the particular dashboard with the user or group at a time. Also, sharing the dashboard with the user/group doesnot share the corresponding reports with them automatically.
In order to do that, admin or report owner should open each report and share them individually.
If the dashboard has more reports i.e 20+, then it'll take a considerable amount of time to complete this task.
To reduce the manual effort, we can use this custom logic to share all the reports from the particular dashboard at a time.

**Pre-requisite:**
A database view which shows the reports shared with atleast one dashboard need to be created.
ServiceNow community article link which explains how to build one..(Thanks to Adam Stout for this)
https://www.servicenow.com/community/performance-analytics-blog/view-reports-on-a-dashboard-and-dashboards-using-a-report/ba-p/2271548

**Components:**
1. UI Page: It contains Jelly script (HTML), Client script and Processing script. Used to capture the user/group info and share the rports with them.
2. UI Action(Client): Created on the Dashboards (pa_dashboards) table. Used to open the UI page as apopup/modal window

This UI action is visible on the dashboard properties page (image attached)

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
UI Page details
Name: sj_share_reports
Category: General
-->

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<input type="hidden" id="key" name="key" value="${sysparm_key}"/>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>


<div class="modal-body">
<div class="row form-section form-group">
<div class="control-label">
<div><p><b> Select the group: </b></p></div>
<div>
<g:ui_reference name="group" id="group" query="active=true" table="sys_user_group" field="name"/>
</div>
<div><p><b> Select the user: </b></p></div>
<div>
<g:ui_reference name="user" id="user" query="active=true" table="sys_user" field="name;user_name;email"/>
</div>
</div>
</div>
</div>
<footer class="modal-footer">
<button class="btn-primary btn" style="min-width:5em" onclick="return onSubmit();" name="submit" id="submit">Share</button>
<button class="btn-danger btn" style="min-width:5em" onclick="return onCancel();" name="cancel" id="cancel">Cancel</button>
</footer>
</g:ui_form>

</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function onCancel() {
var c = gel('cancelled');
c.value = "true";
GlideModal.get().destroy();
return false;
}

function onSubmit() {
return true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
if (cancelled == "false") {
var dashboard_id = key; // sys id of the dashboard from the Jelly script
var group_id = group; // sys id of group from the Jelly script
var user_id = user; //sys id of user from the Jelly script

if (!gs.nil(group_id) || !gs.nil(user_id)) {
groupShare(dashboard_id, group_id);
userShare(dashboard_id, user_id);
response.sendRedirect("pa_dashboards.do?sys_id=" + key);
} else {
response.sendRedirect("pa_dashboards.do?sys_id=" + key);
gs.addErrorMessage("Please select group/user");
}
} else {
response.sendRedirect("pa_dashboards.do?sys_id=" + key);
}

function groupShare(dashboard_id, group_id) {
var db_view = new GlideRecord('u_reports_shared_with_dashboard'); // Database view name
db_view.addEncodedQuery('repstat_report_sys_id!=^dt_dashboard=' + dashboard_id);
db_view.query();
while (db_view.next()) {
var report_id = db_view.rep_sys_id;

var rec = new GlideRecord("sys_report");
rec.get(report_id);
rec.user = "group";
rec.update();

var report_sharing = new GlideRecord('sys_report_users_groups');
report_sharing.addQuery('group_id', group_id);

report_sharing.addQuery('report_id', report_id);
report_sharing.query();
if (!report_sharing.next()) {
var new_record = new GlideRecord('sys_report_users_groups');
new_record.initialize();
new_record.report_id = report_id;
new_record.group_id = group_id;
new_record.insert();
}

}
}

function userShare(dashboard_id, user_id) {
var db_view = new GlideRecord('u_reports_shared_with_dashboard');
db_view.addEncodedQuery('repstat_report_sys_id!=^dt_dashboard=' + dashboard_id);
db_view.query();
while (db_view.next()) {
var report_id = db_view.rep_sys_id;

var rec = new GlideRecord("sys_report");
rec.get(report_id);
rec.user = "group";
rec.update();

var report_sharing = new GlideRecord('sys_report_users_groups');
report_sharing.addQuery('user_id', user_id);
report_sharing.addQuery('report_id', report_id);
report_sharing.query();
if (!report_sharing.next()) {
var new_record = new GlideRecord('sys_report_users_groups');
new_record.initialize();
new_record.report_id = report_id;
new_record.user_id = user_id;
new_record.insert();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
UI Action details:

Active: True
Name: Share reports
Table: Dashboard [pa_dashboards]
Order: 1000
Action name: share_report
Show update: True
Client: True
List v2 Compatible: True
Form button: True
Form style: Primary
Onclick: shareReport();

*/

function shareReport() {
var modal = new GlideModal("sj_share_reports"); // UI Page id
modal.setTitle("Share Reports");
modal.setPreference('sysparm_key', g_form.getUniqueValue());
modal.render();
}
Loading