Check conflicts on change requests

Maria DeLaCruz
Tera Guru

Is there a way to have "check conflicts" automatically run upon submission of a change request?

7 REPLIES 7

Abhinandan Pati
Giga Guru

Hi Maria,



Just call 'Check Conflicts' method from 'Submit' UI Action of Change Request.


Thanks.   I will give that a try.


richard_selby
Kilo Guru

I disabled the UI Action, and created a Business Rule running before insert / update on the Change Request table.


The script was a slightly modified version of the server-side code you find in the Check Conflicts UI Action.



In case it helps, here's the Business Rule I used to Check Conflicts.


Name: Check Conflicts
Table: Change Request


Advanced: yes


When: before


Insert: yes


Update: yes


Filter conditions:


Planned Start Date is not empty AND


Planned End Date is not empty AND


Configuration Item is not empty



And this goes in the script section.



function onBefore(current, previous)


{


  //   Slimmed down version of OOTB Check Conflicts UI Action.


  //   It's better to automatically check for conflicts on saving,


  //   rather than forcing users to click a UI Action link.




  suppressMaintenanceScheduleMessages = true;


  var conflictDetector = new ChangeCheckConflicts(current);


  var conflictResults = conflictDetector.check();


   


  current.conflict_status = 'No Conflict';


  var msg = '';




  if (conflictResults < 0) {


  // Shouldn't happen, as CI is a condition of the rule running


  msg = gs.getMessage('Configuration Item needed for conflict analysis');


  }


  else if (conflictResults == 0) {


  // Msg commented out. Assume no news is good news!


  //msg = gs.getMessage('There are <FONT COLOR="green">NO CONFLICTS</FONT>');


  }


  else {


  msg = gs.getMessage('There are <FONT COLOR="tomato">Schedule Conflicts</FONT> - see "Conflicts" tab at bottom of ticket for details.');


  current.conflict_status = 'Conflict';


  }




  if (msg != '') {


  gs.addInfoMessage(msg);


  action.setRedirectURL(current);


  }


}