Making customization in Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi Everyone,
I have created a custom widget that displays a list of Incidents. Now, I want to show the variables (coming from a Record Producer) inside this widget as part of the list (e.g., as a column).
Currently:
The Incident record is also creating from Record Producer.
The variables submitted via the Record Producer are visible on the Incident form (at the bottom via Variable Editor).
However, these variables are not visible in the form layout and also not appearing in my custom widget.
What I need:
Display Record Producer variables (Variable Editor data) inside my custom widget (Incident list).
Ideally, show them as columns or part of each record output.
I have already:
Checked Form Layout but couldn’t find the Variable Editor field.
Tried searching for solutions but couldn’t figure out how to fetch/display variables in the widget.
This is my code for custom widget:
html:
<div class="incident-widget">
<h3>Incident List</h3>
<table class="incident-table">
<thead>
<tr>
<th>Number</th>
<th>Short Description</th>
<th>Priority</th>
<th>Assigned To</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="inc in data.incidents">
<td>{{inc.number}}</td>
<td>{{inc.short_description}}</td>
<td>
<span class="priority priority-{{inc.priority}}">
{{inc.priority}}
</span>
</td>
<td>{{inc.assigned_to}}</td>
</tr>
</tbody>
</table>
css:
.incident-widget {
padding: 15px;
background: #fff;
border-radius: 8px;
}
.incident-table {
width: 100%;
border-collapse: collapse;
}
.incident-table th {
background: #007bff;
color: white;
padding: 10px;
text-align: left;
}
.incident-table td {
padding: 10px;
border-bottom: 1px solid #ddd;
}
.incident-table tr:hover {
background-color: #f5f5f5;
}
/* Priority colors */
.priority-1 {
color: red;
font-weight: bold;
}
.priority-2 {
color: orange;
}
.priority-3 {
color: green;
}
.priority-4 {
color: blue;
}
client script:
function($scope) {
console.log("Incident widget loaded");
}
server script:
(function() {
data.incidents = [];
data.count = 0;
var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.orderByDesc('sys_created_on');
gr.setLimit(10);
gr.query();
while (gr.next()) {
data.incidents.push({
number: gr.getDisplayValue('number'),
short_description: gr.getDisplayValue('short_description'),
priority: gr.getDisplayValue('priority'),
assigned_to: gr.getDisplayValue('assigned_to') || 'Not Assigned'
});
}
data.count = data.incidents.length;
gs.info("Widget Incident Count: " + data.count);
})();
need to show'Optional Software (backend name: optional_software) and Additional software requirements (u_asr) variables as column in widget.
Thanks in Advance.
