- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 11:55 AM
This is what I have done so far.
1. Created widget called My Assets.
2. Here is my html code:
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);
}
})();
3. I went to SP and added the My Assets but nothing shows up that's assigned to me.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2020 02:21 PM
Attached XML (Widget: assets) as well for reference. In addition, make sure the the server side code is sufficed i.e. atleast an asset or two is assigned to your profile.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:32 AM
Hi John,
You need to create Menu Option from Service Portals >> Portals. Then look for required portal & then look for the field Main Menu. Open the Main Menu page & then scroll to the Related list & add new entry: My Assets.
Script:
// only show 30 in header menu dropdown
var max = 30;
var t = data;
data.count = 0;
var items = data.items = [];
var u = gs.getUser().getID();
items.record_watchers = [];
items.record_watchers.push({'table':'alm_asset','filter':'assigned_to=' + u.toString()});
var z = new GlideRecord('alm_asset');
z.addQuery("assigned_to", u);
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
var a = {};
var title = z.display_name.toString() ;
addCI(title, z.sys_id);
}
function addCI(title, query) {
data.count++;
var link = {};
link.title = title;
link.type = 'link';
link.href='?id=index'; //redirects to homepage if required create a new page with named myassets & uncomment below & comment this one
//link.href = '?id=myassets&table=alm_asset&view=asset_portal&sys_id=' + query;
items.push(link);
}
//Uncomment below to get View all Assets message on the top
//var link = {title: gs.getMessage('View all Assets'), type: 'link', href: '?id=index', items: []};
//items.unshift(link); // put 'View all Assets' first
Output:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 04:40 AM
But I can't click on the assets after adding the script. I can see it but not click on it to open the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 04:41 AM
Try to click on any of your assets and it won't open it up. How can I make that they can click on the asset and it takes them to it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 04:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 05:26 AM
Can you show me how to set that page up?