Create a My Devices Tab and My Reports Device (assets) widget in My Profile Tab in Employee Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 09:27 AM - last edited a week ago
This guide demonstrates how to use OOB Tab Widget Mappings to deploy a custom widget in the "My Profile" tab. This single widget dynamically displays personal assets for employees and allows managers to view their direct reports' devices.
each manager then can click in the My Team widget open the Direct report Employee and see their devices in their profile (Thanks to Anderw S. for the cool trick of having the widget pick the sys_id from the URL)
Create a widget in the sp_widget table
HTML:
<div class="panel panel-default b">
<div class="panel-heading">
<h3 class="panel-title">${My Assets}</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-responsive">
<tr>
<th >
${Model}
</th>
<th>
${Hostname}
</th>
</tr>
<tr ng-repeat="asset in data.assets">
<td >
{{asset.model}}
</td>
<td >
{{asset.ci}}
</td>
</tr>
</table>
</div>
</div>
Server:
(function() {
data.userID = $sp.getParameter("sys_id");
data.assets = [];
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('');
gr.addQuery('assigned_to',data.userID);
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 + '';
asset.model = gr.model_category.name + '';
asset.install_status = gr.install_status.getDisplayValue() + '';
asset.cost = gr.cost.getDisplayValue() + '';
asset.ci = gr.ci.name + '';
asset.serial_number = gr.serial_number + '';
asset.assigned = gr.assigned + '';
//gs.addInfoMessage("DEBUG JP >>>>" + asset.model);
data.assets.push(asset);
}
})();
To create a Tab Widget Mapping, create a record in the sn_employee_tab_widget_mapping table that maps the newly created widget to the Overview tab:
Make sure the employee profile plugin is installed and:
1) Create an Employee Definition here: /sn_employee_definition_list.do
2) Opt-in the employee profile here: /sn_employee_profile_optin_ui_list.do
3) Create a record for each user that you want to show the Employee profile: /sn_employee_profile_list.do as an example "system administrator" and "Abel Tuter"
4) To test add to the Managers field of "Abel Tuter" the value of: System Administrator.