Custom Check Conflicts UI Action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 03:42 PM
Hi Community,
We have a need to have 2 different UI Actions for the 'Check Conflicts'. The first one is fine that checks the CI (cmdb_ci) field, but another area of our organization only displays a custom CI extension table when certain other fields are populated. So what I am trying to achieve is a copy of the original UI Action that checks the other field instead of the cmdb_ci field, which is u_business_system field.
Is there a way to do this? I am not fussed about both UI Actions displaying, but I want to make sure that this is capable of being done.
1. Check Conflicts (OOTB)
2. Check Conflicts - Clients (Additional pointing at the other field)
Any advise would be greatly appreciated.
Thanks,
Josh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 07:52 PM
Would you ever have to check both fields at the same time? I think I would modify the oob UI action adding an IF statement that determines which one to check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2015 08:08 PM
We would never need to do both, based on a field it is one or the other that shows up.
Could you provide me some guidance on the script? My skills in that area are not super strong.
Thanks for your assistance.
-Josh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2015 10:30 AM
It's hard for me to test but might get you close:
function clientCheckFields() {
var ci = g_form.getValue('cmdb_ci')
var bs = g_form.getValue('u_business_service')
var e = $("conflict_msg");
if (e) e.remove();
var fields = "";
var i = 0;
if (g_form.getControl("start_date") && g_form.getValue("start_date") == "") {
fields += ", " + g_form.getLabelOf("start_date");
i++;
}
if (g_form.getControl("end_date") && g_form.getValue("end_date") == "") {
fields += ", " + g_form.getLabelOf("end_date");
i++
}
if (ci != '')
if (g_form.getControl("cmdb_ci") && g_form.getValue("cmdb_ci") == "") {
fields += ", " + g_form.getLabelOf("cmdb_ci");
i++
}
if (bs != '')
if (g_form.getControl("u_business_system") && g_form.getValue("u_business_system") == "") {
fields += ", " + g_form.getLabelOf("u_business_system");
i++
}
if (i > 1) {
g_form.addErrorMessage(getMessage("To check conflicts, the following fields need values") + ": " + fields.substring(2), "conflict_msg");
return false;
}
else if (i == 1) {
g_form.clearMessages();
g_form.addErrorMessage(getMessage("To check conflicts, the following field needs a value") + ": " + fields.substring(2), "conflict_msg");
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'check_conflicts'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
checkConflicts();
function checkConflicts() {
//Array which stores fields that dont have a value
var fieldArray = [];
//Put Start date label in array if it doesnt have a value
if(current.start_date.nil())
fieldArray.push(current.start_date.getLabel());
//Put End date label in array if it doesnt have a value
if (current.end_date.nil())
fieldArray.push(current.end_date.getLabel());
//Put CMDB CI label in array if it doesnt have a value
if(current.cmdb_ci.nil() && current.u_business_service.nil())
if (current.cmdb_ci == '')
fieldArray.push(current.cmdb_ci.getLabel());
else if (current.u_business_service == '')
fieldArray.push(current.u_business_service.getLabel());
//If there are values stored in the array then print message
if(fieldArray.length > 0) {
var fieldMsg = '';
for (var i=0; i < fieldArray.length; i++) {
fieldMsg += fieldArray[i] + ", ";
}
fieldMsg = fieldMsg.substring(0, fieldMsg.length - 2);
gs.addErrorMessage(gs.getMessage("To check conflicts, the following fields need values") + ": " + fieldMsg);
current.update();
action.setRedirectURL(current);
return;
}
//else If there are NO values stored in the array execute the action
else if (fieldArray.length == 0) {
suppressMaintenanceScheduleMessages = true;
var conflictDetector = new ChangeCheckConflicts(current);
var conflictResults = conflictDetector.check();
current.conflict_status = 'No Conflict';
var msg;
if (conflictResults < 0)
msg = gs.getMessage('Configuration Item needed for conflict analysis');
else if (conflictResults == 0)
msg = gs.getMessage('There are <FONT COLOR="green">NO CONFLICTS</FONT>');
else {
msg = gs.getMessage('There <FONT COLOR="tomato">ARE CONFLICTS</FONT> - See "Conflicts" related list');
current.conflict_status = 'Conflict';
}
gs.addInfoMessage(msg);
current.update();
action.setRedirectURL(current);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2015 03:09 PM
That is absolutely fantastic! A couple of typos, but it works...except. Now how do I get the extended CI table to display correctly on the Conflicts tab? Would I build a new one? I added the field, but it is not displaying any information. Nor is the Conflict Type (Blackout)