Create functionality to showcase asset assignment history on the user profile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2023 04:48 AM
Hello Team,
Greetings from Kalyani.
My requirement is like this:
Create functionality to showcase asset assignment history on the user profile. A New widget will be created on the service portal which will display asset assignment history on the user profile.
Could you please help me here?
Thank you in advance.
Regards,
Kalyani Shaha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 12:10 AM
This seems an interesting use case. One thing to remember here is that the user was assigned an asset, and it may have been returned. So you will need to look at the audit history of the assigned to and ensure to list all assets. You can build a related list with date fields as you might want to indicate asset assignment period.
I am not sure if you have performance analytics, if yes then going forward the asset assignment data points can be collected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 10:16 AM
Hello @Kalyani21 ,
I am providing you with the server side and html code to add it to your widget which will be very helpful for you to start your requirement.
******Server script***********
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.asset_history = [];
var userID = gs.getUserID();
var almGR = new GlideRecord('alm_asset');
almGR.addQuery('assigned_to', userID);
almGR.orderByDesc('sys_updated_on');
almGR.query();
while (almGR.next()) {
var asset = {};
asset.name = almGR.model.getDisplayValue();
asset.assignment_date = almGR.sys_updated_on.getDisplayValue();
data.asset_history.push(asset);
}
})();
4. **HTML Template**: Create an HTML template that will display this information in a readable format. This code will go in the 'HTML Template' section of your widget form.
******************HTML************************
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Asset Assignment History</h3>
</div>
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th>Asset Name</th>
<th>Assignment Date</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="asset in c.data.asset_history track by $index">
<td>{{::asset.name}}</td>
<td>{{::asset.assignment_date}}</td>
</tr>
</tbody>
</table>
</div>
</div>
<no-data ng-if="c.data.asset_history.length == 0"></no-data>
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 10:36 AM
Hi @Kalyani21 ,
Here we need to deal with Asset(alm_asset), user(sys_user), and Audit History tables. For the same use case, we have built a database view by merging all these 3 tables (not in portal widgets).
Note: As per SNOW best practices, Reports (or) database views on the Audit (or) Audit History table are not recommended. It will impact system performance.
**Please Hit Correct, Helpful, or like, if you are satisfied with this response.
Thanks & Regards,
Sumanth Meda.