How to check if there are any Open Incidents/Changes/Problems to stop closure of an Incident

Hi Experts,

I need to stop the closure of the Incident if there are any Open Records. Can someone please let me know how that can be achieved.

I found on help center the following method to close the related Workorders. Can I get some help to build similar Logic for other Tickets

Modify im.set.close Process definition

This process needs to be modified so that a user cannot close an incident if there are work orders still open for the incident.

To modify a process definition record, follow these steps:

  1. From the System Navigator, click Tailoring > Document Engine > Processes to open the Process Definition form.
  2. Type im.set.close in the Process Name field.
  3. Click Search.
  4. On the Initial Javascript tab, type the following JavaScript:

    var WO=new SCFile ("EXWorkOrder")
    var FoundOpenWO=WO.doSelect ("RelatedID=\"" system.vars.$L_
    file.number   "\"" " and status ~=\""   "Closed"   "\""
    if (FoundOpenWO == RC_SUCCESS)
    {
    system.vars.$openWO=true;
    }
    else
    {
    system .vars.$openWO=false;
    }
  5. Click Save.
  6. On the RAD tab, enter the following information:

    Field Value Note: Some of the fields on the RAD tab are pre-filled with values that you do not need to modify RAD Application - Select the empty section below the section calling the RAD Application us.consume.wrapper and then enter the following information: Expressions evaluated before RAD call $L.text="There are still open work orders. This incident cannot be closed yet." RAD Application apm.mb.ok Condition $openWO=true Parameter Names text Parameter Values $L.text
  7. Click Save.
  8. On the Final Expressions tab, enter the following information:

    • if ($openWO=true) then ($L.exit="badval")
    • $L.exit="closestate"
  9. Click Save and then OK.

 

 

Here I am not able to understand what is this ""

system.vars.$openWO=true;

 

DO we have similar check points for other records.

Regards,

-HB 

  • It's usually helpful to do a search on this board before posting, to see if a thread has already given some tips. For example, this recent thread: http://community.hpe.com/t5/Service-Manager-Service-Center/Stop-Mater-Ticket-Closure-before-Child-Tickets-are-closed/m-p/6886234

    That being said, I would do this with a calculation or a JavaScript on the probsummary formatctrl, to check if there are any open related records, and if there are establish a variable. Then in that same formatctrl, validate that variable on close.

  • @AChandler

    Thanks for the reply..

     

    I had already checked the thread mentioned by you but that didn't worked.

    Can you please help with JS you mentioned earlier

    Regards,

    -HB

  • Hi @HPSMBeginner, could you tell me what you are using for Workorders? Are they in the incident module, just named differently?

  • Well, I guess it may not matter which module your workorders are on. Try this first and see what it does:

    Put this in the probsummary formatctrl on the Javascript tab, with Del set to true:

    vars.$hasRelated = "NOPE"
    
    var rel = new SCFile("screlation");
    var q = "source=\""   record.number   "\" and depend.active=true";
    
    var relRc = rel.doSelect(q);
    
    if (relRc == RC_SUCCESS) {vars.$hasRelated = "YEP"}

    Then on the Validations tab, add a line with Del as true and the Validation saying

    $hasRelated="NOPE"

    Then test it out by trying to close an Incident that has an open workorder.

    If your Workorders are in the IM module and you only care about open Workorders (no other open tickets) when closing an Incident, then use this for the JS instead (adding the table name should improve query time):

    vars.$hasRelated = "NOPE"
    
    var rel = new SCFile("screlation");
    var q = "source=\""   record.number   "\" and depend.active=true and depend.filename=\"probsummary\"";
    
    var relRc = rel.doSelect(q);
    
    if (relRc == RC_SUCCESS) {vars.$hasRelated = "YEP"}

     

  • @AChandler

     

    I am not using workorders. I want the similar workflow to check any Open Incidents,Problem or Change Requests related to an Incident.

     

    To simplify the Use case is as follows

    If a User tries to close the Incident, and there are any open Incidents, Prolems or Change records related to that Incident, the system should throw an Error.

    I found the snippet of the code in the helpcenter, but this is not meeting my requirement

     

    -HB

  • OK, so try what I posted earlier.

    In the probsummary formatctrl, put this JS on Delete:

    vars.$hasRelated = "NOPE"
    
    var rel = new SCFile("screlation");
    var q = "source=\""   record.number   "\" and depend.active=true and (depend.filename=\"probsummary\" or depend.filename=\"rootcause\" or depend.filename=\"cm3r\")";
    
    var relRc = rel.doSelect(q);
    
    if (relRc == RC_SUCCESS) {vars.$hasRelated = "YEP"}

    then put a validation on Delete saying this:

    $hasRelated="NOPE"

    Then try to close an Incident which has an open IM or PM or C.