Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Manage Report to view employee tasks and incidents

amber_pearson
Giga Contributor

Hi All,

I am trying to develop a way for non-itil users to see their respective employees tasks and incidents. Our instance pulls manager information from AD. I do not want to add additional licenses for this (so no role will be given to the manager); also I do not want to change all our ACL's for the managers to view the information. I believe the best way to do this is to provide a report that is emailed to the manager with the Incidents and Tasks associated to that manager's employees. We would like this to be a service catalog item that is automatically completed. Is there a way to trigger a report from a workflow? Running the report manually I can use caller.manager = the manager's name. How can I pass the variable from the workflow script to the report? Also, I would need the report to ultimately be emailed to the manager.

I appreciate your help!

Amber

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Unfortunately, you will not be able to use the manager's ID dynamically in a normal report.   However, seeing as you want to email the results to the managers anyways, this post may help you out - Using Email Notifications as Custom Reports



Instead of creating a Scheduled Job, you can fire the event from your catalog item, or maybe create a Record Producer to save you from creating a workflow as well.   Record Producers can be configured to not actually create a record - Use a Record Producer to NOT CREATE A RECORD.   That may be better as your managers can request a report and you will not have Requests, Requested Items and Workflows being created for nothing.


View solution in original post

5 REPLIES 5

Jim Coyne
Kilo Patron

Unfortunately, you will not be able to use the manager's ID dynamically in a normal report.   However, seeing as you want to email the results to the managers anyways, this post may help you out - Using Email Notifications as Custom Reports



Instead of creating a Scheduled Job, you can fire the event from your catalog item, or maybe create a Record Producer to save you from creating a workflow as well.   Record Producers can be configured to not actually create a record - Use a Record Producer to NOT CREATE A RECORD.   That may be better as your managers can request a report and you will not have Requests, Requested Items and Workflows being created for nothing.


amber_pearson
Giga Contributor

Thanks Jim for pointing me in the right direction. I have decided to use email notification to email the custom report. All is working except for a piece of the query "gr.addQuery('caller_id.manager.name','current.requested_for.name');" I believe it is an issue with the variable name of the Requested For since it works if I put in a person's name there. Could someone clarify what the variable name should be?




Self-Service Workflow:


Creates Task with the short description: Manager Report




Notification details:


table:sc_task


when: Short Description: Manager Report



<mail script>


baseUrl=gs.getproperty("glide.servlet.uri");


var gr=new GlideRecord("incident");


gr.addQuery('active','true');


gr.addQuery('caller_id.manager.name','current.requested_for.name');


gr.orderBy('caller_id.user_name');


gr.setLimit(15);  


gr.query();


if (gr.getRowCount() > 0)  


{template.print(gr.caller_id.user_name + "<br/>");


  while (gr.next())


  {template.print(gr.caller_id.user_name + "</a> - " + gr.getDisplayValue('sys_created_on') + " - <a href='" + baseUrl + gr.getLink() + "'>" + gr.getValue('number') + "</a> - " + gr.short_description + "<br/>");  


  }


}


<mail script>


Try removing the quotes around the "current.requested_for.name" string:




gr.addQuery('caller_id.manager.name',current.requested_for.name);



You are literally sending "current.requested_for.name" as the name to look for instead of the field value.   And I'm wondering if it should be current.requested_for.manager.name?


amber_pearson
Giga Contributor

That worked!!



The reason I am feeding in the requested for as the caller's manager is because this will be requested by the manager in the self-service portal. Therefore the requestor (requested for) will also be the caller's manager.