Skip to content

Commit 13c1aa1

Browse files
authored
Open In platform button - enhancement (#2460)
1 parent bc7be8f commit 13c1aa1

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
**This is an enhancement to the current code**
2-
1. Added "open in SOW" Button to open the record in service operations workspace, since it is gaining popularity now.
2+
1. Added "open in Workspace" Button to open the record in workspace(defined in option schema), since it is gaining popularity now.
33
2. Enhanced the visibility condition so that the button is only visible on pages having sys_id and table in url.
44
3. Enhanced css to improve visibility of button.
5+
4. This button wll look for the table to workspace mapping (in option schema) and create the URL to open record in respective workspace. If now mapping is found, the record is opened in SOW workspace(default).
6+
5. The button name has been changed to generic title "Open In Workspace"
57

6-
Widget will create a button that will only be visable to users with the itil role that will take them to the same record in platform. will work with the form and standard ticket pages (or anywhere with the table and sysId in the url.
8+
**Sample**
9+
{
10+
"name":"define_workspace",
11+
"type":"json",
12+
"label":"Define Table Workspace JSON Mapping",
13+
"value":{
14+
"sn_grc_issue":"risk/privacy", // will open issue records in RISK workspace
15+
"sn_si_incident":"sir" // will open security incidents in SIR workspace.
16+
}
17+
}
18+
19+
Widget will create a button that will only be visible to users with the itil role that will take them to the same record in platform. will work with the form and standard ticket pages (or anywhere with the table and sysId in the url.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
22
<span class="btn-cntr" ng-if="::data.role==true">
33
<a href="{{::data.platform_url}}" target='_blank'class='btn btn-default'>{{::options.open_in_platform}}</a><br> <!--Platform button configuration-->
4-
<a href="{{::data.sow_url}}" target='_blank'class='btn btn-default'>{{::options.open_in_sow}}</a> <!--SOW button configuration-->
4+
<a href="{{::data.workspace_url}}" target='_blank'class='btn btn-default'>{{::options.open_in_workspace}}</a> <!--Workspace button-->
55
</span>
66
</div>

Modern Development/Service Portal Widgets/Open in Platform/option schema.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@
66
"default_value":"Open in Platform"
77
},
88
{
9-
"name":"open_in_sow",
9+
"name":"open_in_workspace",
1010
"type":"string",
11-
"label":"Name for SOW Button",
12-
"default_value":"Open in SOW"
11+
"label":"Name for Workspace Button",
12+
"default_value":"Open In workspace"
13+
},
14+
{
15+
"name":"define_workspace",
16+
"type":"json",
17+
"label":"Define Table Workspace JSON Mapping",
18+
"value":{
19+
"sn_grc_issue":"risk/privacy",
20+
"sn_si_incident":"sir"
21+
}
1322
}
1423
]

Modern Development/Service Portal Widgets/Open in Platform/server.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
(function() {
22
/*
3-
Code will get table and sys_id parameter from url and create url for platform and sow.
3+
Code will get table and sys_id parameter from url and create url for platform and workspace(defined in option schema).
44
This widget can be used in any page having sys_id and table in url , eg: ticket page.
55
*/
6-
data.table = input.table || $sp.getParameter("table"); // get table from url
7-
data.sys_id = input.sys_id || $sp.getParameter("sys_id"); // get sys_id from url
6+
data.table = $sp.getParameter("table"); // get table from url
7+
data.sys_id = $sp.getParameter("sys_id"); // get sys_id from url
88

9+
var tableWorkspaceMapping = JSON.parse(options.define_workspace); // get the table to workspace mapping from instance options.
10+
Object.keys(tableWorkspaceMapping).forEach(function(key) {
11+
if (key == data.table)
12+
data.workspace_url = "now/" + tableWorkspaceMapping[key] + "/record/" + data.table + "/" + data.sys_id; // if table to workspce mapping is found, the create workspace URL.
13+
else
14+
data.workspace_url = "now/sow/record/" + data.table + "/" + data.sys_id; // open in SOW
15+
});
916
data.platform_url = "/nav_to.do?uri=" + data.table + ".do?sys_id=" + data.sys_id;
10-
data.sow_url = "now/sow/record/" + data.table + "/" + data.sys_id;
1117

1218
data.role = false;
1319
if (gs.hasRole("itil") && data.table && data.sys_id) { // only visible to users with itil role and if url has required parameters.

0 commit comments

Comments
 (0)