Handovering CI to Configuration Item

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2024 09:40 AM - edited ‎05-29-2024 11:25 AM
On incident form, next to caller field, I have "Show Related Devices" icon. After clicking on it, all the assets assigned to the user are showing in a list. I want the functionality enabled that if I select any asset then it should show in configuration item field. I'm unable to achieve this functionality. Can anyone please help ?
For this I have UI Page :
<?xml version="1.0" encoding="utf-8" ?>
<!--j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"> -->
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<g:set var="table" value="${table}" />
<g:set var="view" value="${sysparm_view}" />
<g:set var="query" value="${sysparm_query}" />
<g:set var="title" value="Device List"/>
<g:if test="${table}">
<g:table tree="false" table="${table}" view="${view}" query="${query}" start="0" end="100" name="user_show_hardwares_${jvar_guid}">
<j:script>
// Add click event to each row to set the value in the parent form
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('tr.list_row').forEach(function(row) {
row.addEventListener('click', function() {
var sys_id = row.getAttribute('sys_id');
if (sys_id) {
window.top.g_form.setValue('cmdb_ci', sys_id);
window.top.GlideDialogWindow.get().destroy(); // Close the dialog window
}
});
});
});
</j:script>
</g:table>
</g:if>
</j:jelly>
and a Macro :
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="user_show_hardwares_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedList12('${ref}'); "
title="${gs.getMessage('Show Related Devices')}" image="images/icons/tasks.gifx" icon="icon-hardware"/>
<script>
function showRelatedList12(reference) {
var s = reference.split('.');
// Get the field name which is always last
var referenceField = s[s.length - 1];
var v = g_form.getValue(reference);
var w = new GlideDialogWindow('custom_show_list');
w.setTitle('Showing devices assigned to:'+g_form.getDisplayBox(reference).value);
w.setPreference('table', 'cmdb_ci_hardware_list');
w.setPreference('sysparm_view', 'default');
w.setPreference('sysparm_query', 'assigned_to' + '=' + v);
w.render();
}
</script>
</j:jelly>