diff --git a/Modern Development/Service Portal Widgets/My Assets/README.md b/Modern Development/Service Portal Widgets/My Assets/README.md new file mode 100644 index 0000000000..e8f647551e --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Assets/README.md @@ -0,0 +1,22 @@ +# My Assets Widget + +## Overview +Displays assets assigned to the logged-in user in a clean, responsive table. +Data is fetched from the `alm_asset` table using a secure server script. + +## Files +- **HTML** – Defines the widget layout and table structure +- **Server Script** – Retrieves user-specific assets from `alm_asset` +- **CSS** – Adds modern, responsive styling + +## Features +- Responsive table layout +- Record count badge +- Hover and gradient effects +- Empty state message + +## Usage +1. Navigate to **Service Portal > Widgets** in ServiceNow. +2. Create a new widget and paste the HTML, Server Script, Client Script, and CSS. +3. Save the widget and add it to your desired portal page. +4. The widget automatically displays assets assigned to the logged-in user. diff --git a/Modern Development/Service Portal Widgets/My Assets/my_assets.css b/Modern Development/Service Portal Widgets/My Assets/my_assets.css new file mode 100644 index 0000000000..742b626f11 --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Assets/my_assets.css @@ -0,0 +1,41 @@ +.my-assets-widget { + border-radius: 12px; + box-shadow: 0 2px 10px rgba(0,0,0,0.08); + overflow: hidden; +} + +.my-assets-widget .panel-heading { + background: linear-gradient(90deg, #0078d4, #005fa3); + color: #fff; + padding: 12px 16px; + font-weight: 500; +} + +.my-assets-widget .panel-heading .badge { + background-color: #fff; + color: #005fa3; + font-weight: 600; +} + +.my-assets-widget .table { + margin-bottom: 0; +} + +.my-assets-widget .table-hover tbody tr:hover { + background-color: #f2f8ff; + cursor: pointer; +} + +.my-assets-widget .asset-link { + font-weight: 500; + color: #0078d4; + text-decoration: none; +} + +.my-assets-widget .asset-link:hover { + text-decoration: underline; +} + +.my-assets-widget .panel-body.text-center { + padding: 30px; +} diff --git a/Modern Development/Service Portal Widgets/My Assets/my_assets.html b/Modern Development/Service Portal Widgets/My Assets/my_assets.html new file mode 100644 index 0000000000..cf6994ce88 --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Assets/my_assets.html @@ -0,0 +1,45 @@ +
diff --git a/Modern Development/Service Portal Widgets/My Assets/my_assets_server_side.js b/Modern Development/Service Portal Widgets/My Assets/my_assets_server_side.js new file mode 100644 index 0000000000..ea1367f9c8 --- /dev/null +++ b/Modern Development/Service Portal Widgets/My Assets/my_assets_server_side.js @@ -0,0 +1,19 @@ +(function() { + data.userID = gs.getUserID(); + data.assets = []; + + var gr = new GlideRecordSecure('alm_asset'); + gr.addQuery('assigned_to', gs.getUserID()); + gr.orderBy('display_name'); + gr.query(); + + data.recordCount = gr.getRowCount(); + + while (gr.next()) { + data.assets.push({ + display: gr.getDisplayValue('display_name'), + assigned_to: gr.getDisplayValue('assigned_to'), + sysid: gr.getUniqueValue() + }); + } +})();