- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 10:08 AM
Hello everyone,
I am fairly new to the bootstrap space and the whole service portal stuff. One of the requirement is to create a custom widget called 'My Assets' similar to 'My Request' & 'My Approval'. This custom widget should list all the assets assigned to the logged in user.
Any help with the actual script of the widget would be appreciated.
Thanks,
Mohammed
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 04:39 AM
Hi Mohammed,
This is a very simplistic response to what you are looking for. I'm sure you will want to add additional features and functionality.
Go to the Widgets under Service Portal in the navigation
Hit New
Name: My Assets
id: my-assets
HTML:
<h4 class="panel-title">
My Assets
</h4>
<div>
<table>
<tr ng-repeat="asset in data.assets">
<td><a href ="nav_to.do?uri=alm_hardware.do?sys_id={{asset.sysid}}">{{asset.display}}"
</a></td>
</tr>
</table>
</div>
Server Script
(function() {
data.userID = gs.getUserID();
data.assets = [];
var gr = new GlideRecordSecure('alm_asset');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
data.recordCount=gr.getRowCount();
data.assets = [];
while (gr.next()) {
var asset = {};
asset.display = gr.display_name + '';
asset.assigned_to = gr.assigned_to.getDisplayValue();
asset.sysid = gr.sys_id + '';
data.assets.push(asset);
}
})();
Has Preview: Checked
Save your new record and hit the UI Action Open in Widget Editor. Once open in the widget editor hit the Eye looking preview button beside the save button to show you a VERY simple example of a My Assets widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2017 04:39 AM
Hi Mohammed,
This is a very simplistic response to what you are looking for. I'm sure you will want to add additional features and functionality.
Go to the Widgets under Service Portal in the navigation
Hit New
Name: My Assets
id: my-assets
HTML:
<h4 class="panel-title">
My Assets
</h4>
<div>
<table>
<tr ng-repeat="asset in data.assets">
<td><a href ="nav_to.do?uri=alm_hardware.do?sys_id={{asset.sysid}}">{{asset.display}}"
</a></td>
</tr>
</table>
</div>
Server Script
(function() {
data.userID = gs.getUserID();
data.assets = [];
var gr = new GlideRecordSecure('alm_asset');
gr.addQuery('assigned_to',gs.getUserID());
gr.query();
data.recordCount=gr.getRowCount();
data.assets = [];
while (gr.next()) {
var asset = {};
asset.display = gr.display_name + '';
asset.assigned_to = gr.assigned_to.getDisplayValue();
asset.sysid = gr.sys_id + '';
data.assets.push(asset);
}
})();
Has Preview: Checked
Save your new record and hit the UI Action Open in Widget Editor. Once open in the widget editor hit the Eye looking preview button beside the save button to show you a VERY simple example of a My Assets widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 02:51 AM
Hi,
One of the requirement is to create a custom widget called 'My Assets'. This custom widget should list all the assets, but it should be sorted accordingly type of assets assigned to the logged in user. when logged in user clicks on laptop option it should be list of laptops which logged in user having, same as other assets.
Any help with the actual script of the widget would be appreciated.
Thanks,
Dhanashree