The CreatorCon Call for Content is officially open! Get started here.

Parent/Child for HR Case

lwatts
Kilo Contributor

Is there a way to setup parent/child relationships for HR Case.   I know for Incidents you can click Configure > Related Lists and then add then select Incident > Parent Incident.   I am not seeing an option like this for Hr Case (HR Case > Parent HR Case).  

Is this the preferred method for creating Parent and child cases.   I haven't found any clear directions on how to set this up properly so users will have the ability to open a new case, designate it as a master (parent) and link other similar cases to it.   Any comments/state changes made on master cases would flow to child case.

If anyone has any ideas let me know.

Thank you,

Lorenzo

1 ACCEPTED SOLUTION

Cool glad you got the right related list going.   The functionality you describe of updating the children is out of the box and part of Incident Management.   There is a specific Parent Incident field and this is managed in a business rule called "Update Child Incidents".   This functionality doesn't exist on Task because there are field differences but you can definitely clone the Update Child Incidents business rule and set it against the HR Case table and modify it to your needs.



Please mark any of these posts helpful and/or the answer to your question so others can benefit.


View solution in original post

16 REPLIES 16

Ah it appears your instance may have a different table label than my instance.   Its the HR Case->Case related list.


lwatts
Kilo Contributor

Thanks I selected HR Case -> Case and opened an existing Case and was able to select Edit and add cases.   Are any cases I add under HR Cases linked to the case and if I update additional comments on the Case will that flow to the linked cases and if Case is closed will the linked cases automatically close but I'm sure there is probably some other configuration(s) that need to be done.



Thanks


Cool glad you got the right related list going.   The functionality you describe of updating the children is out of the box and part of Incident Management.   There is a specific Parent Incident field and this is managed in a business rule called "Update Child Incidents".   This functionality doesn't exist on Task because there are field differences but you can definitely clone the Update Child Incidents business rule and set it against the HR Case table and modify it to your needs.



Please mark any of these posts helpful and/or the answer to your question so others can benefit.


Hey Michael,



Thanks for your help on this!!   I've been searching for days and could never find any clear directions on how to accomplish this.   I'll work on modifying the Business Rule script to match our needs.



Thanks again!



Lorenzo


Hey Michael,



I have added the business rule and made changes but unable to get the child hr case to update.   I'm not great at scripting but tried to make what I thought are the necessary changes.   Do you mind taking a look at my code below and see if I'm missing something.



condition:   current.isValidRecord() && (current.state.changesTo(-1) || current.comments.changes() || current.work_notes.changes())



updateChildHRCase();


function updateChildHRCase() {


  if (current.state.changesTo(-1))


  resolveChildHR_Case();


  else {


  updateChildren('comments', 'Comment copied from Parent HR_Case');


  updateChildren('work_notes', 'Work notes copied from Parent HR_Case');


  }



}




function updateChildren(fieldName, msg) {


  msg = gs.getMessage(msg);


  var rec = new GlideRecord("hr_case");


  rec.addQuery("parent_hr_case", current.sys_id);


  rec.addQuery("hr_case_state", "!=", hr_caseState.RESOLVED);


  rec.addActiveQuery();


  rec.query();


  while (rec.next()) {


  var fieldRawValue = current.getValue(fieldName) + '';


  var fieldValue = fieldRawValue.trim();


  if (!fieldValue || fieldValue.length <= 0)


  return;


  if (fieldRawValue.indexOf(msg) == 0)


  rec[fieldName] = fieldRawValue;


  else


  rec[fieldName] = msg + ": " + fieldRawValue;


  rec.update();


  }


}




//


// Resolve active, unresolved hr_cases that are children of the current hr_case


//


function resolveChildhr_cases() {


  var hr_case = new GlideRecord("hr_case");


  hr_case.addActiveQuery();


  hr_case.addQuery("parent_hr_case", current.sys_id);


  hr_case.addQuery("hr_case_state", "!=", hr_caseState.RESOLVED);


  hr_case.query();


  var msg = "";


  while (hr_case.next()) {


  gs.print("hr_case " + hr_case.number + ' resolved based on resolution of Parent hr_case ' + current.number);


  hr_case.hr_case_state = hr_caseState.RESOLVED;


  if (hr_case.close_notes.nil()) {


  msg = "Close notes copied from Parent hr_case";


  if (current.close_notes.toString().indexOf(msg) == 0)


  hr_case.close_notes = current.close_notes;


  else


  hr_case.close_notes = msg + ": " + current.close_notes;


  }


  hr_case.close_code = current.close_code;


  msg = "Resolved based on resolution of Parent hr_case.";


  if (current.comments.toString().indexOf(msg) == 0)


  hr_case.comments = current.comments;


  else


  hr_case.comments = msg + " " + current.comments;


  hr_case.work_notes = current.work_notes;


  hr_case.update();


  }


}



Thanks