Reference field is showing sys_id instead of display value but when i reload the form it is working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-14-2024 11:58 PM
Hi All,
When I am updating the install base item in the case form then the service and ci should get updated in the related incident form.
In the workspace when I open both the case and incident form and after updating the install base the service and ci are showing the sys_id but when I reload the incident page then it is showing the display value means it is working when I am reloading the page.
I have written one After BR on Case table
fetchServiceAndCi();
function fetchServiceAndCi() {
var getChild;
var getParent;
var incDetails = current.incident;
var grCIID = current.install_base.configuration_item.getDisplayValue();
var getCI = new GlideRecord('cmdb_ci');
getCI.addQuery("name", grCIID);
getCI.query();
if (getCI.next()) {
var getCIClass = getCI.sys_class_name;
if (getCIClass == "cmdb_ci_service_discovered") {
var service = getCI.sys_id;
var getConfigitem = new GlideRecord("cmdb_rel_ci");
getConfigitem.addQuery("parent", service);
getConfigitem.query();
if (getConfigitem.next()) {
getChild = getConfigitem.child;
getParent = getConfigitem.parent;
}
} else if (getCIClass == "cmdb_ci") {
var getConfigItem = getCI.sys_id;
var getService = new GlideRecord('cmdb_rel_ci');
getService.addQuery("child", getConfigItem);
getService.query();
if (getService.next()) {
getParent = getService.parent;
getChild = getService.child;
}
}
updateIncDetails(getChild, getParent, incDetails);
}
}
function updateIncDetails(getChild, getParent, incDetails) {
var grInc = new GlideRecord('incident');
grInc.addQuery('sys_id', incDetails);
grInc.query();
if (grInc.next()) {
grInc.business_service = getParent.toString();
grInc.cmdb_ci = getChild.toString();
grInc.update();
}
}
0 REPLIES 0