Under the hood question for Granular Delegate Tasks (expert needed)

Jay Michael
Tera Expert

I found surface level information about Granular Delegates/Delegation Rules - but need input from anyone that has experience with the code behind the scenes. My question: "Is there a simple way to see all of the HR Tasks that have been Delegated to me?". I'm only aware of this  OOTB To Do widget that distinguishes which tasks are delegated to me (highlighted, and I have zero clue how its doing that). I don't see any fields on HR Task that are used to distinguish which cases are assigned to me vs delegated to me. I imagine the answer lies embedded in this widget but come on- that thing is scary, time is of the essence, and I don't think my question is TOO complex to merit a simple query/table/relationship that I am missing. Any help would be appreciated and I'll be indebted for life. 


JayMichael_0-1747935840935.png

JayMichael_1-1747936556665.png

 

 

1 ACCEPTED SOLUTION

Jay Michael
Tera Expert

So within the OOTB Script includes that the widget calls - this table is queried: sys_granular_delegate_m2m_list.

 

It links Delegates to the tasks that they have been delegated. However, the sys ids of the HR Task are held in a Document field, so you'll need to do a simple array to get the sys IDs. Below is an example script:

var gr = new GlideRecord("sys_granular_delegate_m2m");
gr.addEncodedQuery("delegate=13b88c671b5fd050fe4421f72a4bcb62"); // 
gr.query();

var taskSysIds = [];

while(gr.next()){
    gs.info("jay " + gr.document.toString());
    taskSysIds.push(gr.document.toString());
}

gs.info("jay final " + taskSysIds.toString());

var hrTask = new GlideRecord("sn_hr_core_task");
hrTask.addEncodedQuery("sys_idIN"+ taskSysIds.toString());
hrTask.query();

gs.info("jay task " + hrTask.getRowCount());



JayMichael_0-1748284158638.png

 

 

View solution in original post

3 REPLIES 3

Jay Michael
Tera Expert

sys_granular_delegate_m2m_list

Jay Michael
Tera Expert

So within the OOTB Script includes that the widget calls - this table is queried: sys_granular_delegate_m2m_list.

 

It links Delegates to the tasks that they have been delegated. However, the sys ids of the HR Task are held in a Document field, so you'll need to do a simple array to get the sys IDs. Below is an example script:

var gr = new GlideRecord("sys_granular_delegate_m2m");
gr.addEncodedQuery("delegate=13b88c671b5fd050fe4421f72a4bcb62"); // 
gr.query();

var taskSysIds = [];

while(gr.next()){
    gs.info("jay " + gr.document.toString());
    taskSysIds.push(gr.document.toString());
}

gs.info("jay final " + taskSysIds.toString());

var hrTask = new GlideRecord("sn_hr_core_task");
hrTask.addEncodedQuery("sys_idIN"+ taskSysIds.toString());
hrTask.query();

gs.info("jay task " + hrTask.getRowCount());



JayMichael_0-1748284158638.png

 

 

Jay Michael
Tera Expert

Upon answering my own question, I became an expert is Granular Delegates so feel free to ask questions about it