Can someone help me with showing my assets assigned to user on SP?

John Vo1
Tera Guru

This is what I have done so far.

1.  Created widget called My Assets.

find_real_file.png

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.

1 ACCEPTED SOLUTION

find_real_file.png

find_real_file.png

 

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.

 

View solution in original post

35 REPLIES 35

Yes, you can.

You can try replacing

link.href = '?id=my_bv_assets&table=alm_asset&view=asset_portal&sys_id=' + query;  

with

 link.href='https://yourinstancename.service-now.com/alm_hardware.do?sys_id='+query;
//replace yourinstancename once & check

for a check.

When I put in that code and go to the SP and I click on my assets no assets shows up.

I guess, table name you use is alm_asset & there one in link is alm_hardware

Can you try replacing the same in the URL for a check.

find_real_file.png

 

Can you try attached XML.

Header Item: My Assets (from Service Portal >> Portals & then Main Menu option)