How to display few checklists in a HR case based on the category selected in a record producer

Arpita Priyadar
Mega Contributor

Ex-

There is a "create a HR case" record producer.when I will raise a request with category value isthen 2 checklist testA1 and testA2 will display in the HR case.

if I will raise a request with Category value is B then 2 checklist  testB1 and testB2 will display in the HR case

Category is lookup selectbox and this field values are dependent on another field lookup selectbox ie what is this request regarding

1 ACCEPTED SOLUTION

Hello @Arpita Priyadarshini  ,

then lets try this we have two tables where check lists and check list items are stored .

1) Check list - where your check list can be created manually .

back end name -checklist.LIST

2) Checklist Item - where check list items are stored 

back end name :checklist_item.LIST

 

find_real_file.png

find_real_file.png

So you can write an after insert BR on hr case table and get the category through script and check if its category A insert a record in checklist table and under that record again insert check list items through script with exact mappings .

Main thing is you need to map document ID field which stores the HR case sys_id.If you try to map it then automatically the check list will be inserted 

sample script 

var gr= new GlideRecord('checklist');
gr.initialize();
gr.document=current.sys_id;
gr.owner =gs.getUserID();
gr.table="sn_hr_core_case";
var checkid = gr.insert();

var arr=['test1' ,'test2']; // store your check list item names
var orderCount=0; 
for(var i=0; i<arr.length; i++)
{
var chck = new GlideRecord('checklist_item');
chck.initialize();
chck.checklist=checkid;
chck.name=arr[i];
chck.order=orderCount++;
chck.insert();
}

Not sure if it will work but worth giving a try .

Please mark my answer correct if it helps you

 

View solution in original post

7 REPLIES 7

it's working now

thanks Mohith

Hi Mohith,

 

What will happen, if the category is changed post insert. How to handle the checklist in this case. What I have found so far is that, it is possible only during insert. Do you know any way where checklist changes based on changes in category or some other field on update?

Instead of a BR, I created a Flow to create these checklists with the help of HR Task Template records to store the various checklists I need. In that Flow I have a Decision table to retrieve the correct template based on a matching criteria. I create a new custom checklist associated to the case and then I use a Lookup Records action to gather the Checklist Items within that template. I can use that lookup results in a For each loop to create a new checklist items to associate back to the case. The Flow runs on insert but waits until the state changes to WIP before proceeding. You could update this process to run on update in any case where you want to remove a checklist and apply another one.