- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 11:49 AM
I have a need to build a dynamic table that will show up on a Catalog item.
I have a table that is used to populate the table. I was looking at some information out on the web and found that this could be done, but not having any luck getting it to produce the results.
I have a Rich Text Label named: efc_access_table that I want the script to populate.
I am using the code here for the Catalog Client Script: But it's not populating anything. The Catalog client script is set for onLoad for the catalog item and I'm not sure why it's not populating
function onLoad() {
// You can replace 'your_table_name' with the actual table you want to query
var gr = new GlideRecord('u_efc_choice');
gr.query();
// Create the HTML for the table dynamically
var tableHtml = '<style>';
tableHtml += 'table { width: 100%; border-collapse: collapse; }';
tableHtml += 'th, td { padding: 8px; text-align: left; border: 1px solid #ddd; }';
tableHtml += 'tr:nth-child(even) { background-color: #f2f2f2; }';
tableHtml += 'tr:nth-child(odd) { background-color: #ffffff; }';
tableHtml += '</style>';
tableHtml += '<table>';
tableHtml += '<thead><tr><th>Security Group</th><th>Description</th><th>Approver1</th><th>Approver2></th><th>Approver 3</th></tr></thead>';
tableHtml += '<tbody>';
// Loop through the records and add rows to the table
var rowCount = 0;
while (gr.next()) {
tableHtml += '<tr>';
tableHtml += '<td>' + gr.getValue('u_security_group') + '</td>';
tableHtml += '<td>' + gr.getValue('u_description') + '</td>';
tableHtml += '<td>' + gr.getValue('u_approver1.name') + '</td>';
tableHtml += '<td>' + gr.getValue('u_approver2.name') + '</td>';
tableHtml += '<td>' + gr.getValue('u_approver3.name') + '</td>';
tableHtml += '</tr>';
rowCount++;
}
tableHtml += '</tbody>';
tableHtml += '</table>';
// Inject the table HTML into the Rich Text field (e.g., with document.getElementById)
g_form.setValue('efc_access_table', tableHtml);
}
Has anyone created one of these that could shed some light on this please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 07:48 AM
I was able to solve me own problem, I was using the g_form.setValue() function but it ended up I needed g_form.setLabelOf() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2025 09:32 AM
Could you help me out with the code on this. I've never done this and am still learning. Would be a great opportunity to learn something 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 07:48 AM
I was able to solve me own problem, I was using the g_form.setValue() function but it ended up I needed g_form.setLabelOf() function.