Employee Center Widgets - Troubleshooting GuideThis article will cover the basic steps for troubleshooting issues with Widgets on the Employee Center (ESC) portal. Table of contents Check the Employee Center versionAre all the Employee Center apps on the same version?Check RCAsImpersonationWhich widget is being used?Page Route MapsThemes and CSSCheck for Widget Customisations, Dependencies, Angular Providers and Angular ng-templatesHow to debug the Widgets' Server Script codeCommon Errors Check the Employee Center version The first thing to do is to check which version of these apps: Employee CenterEmployee Center CoreEmployee Center Pro (if installed)Content ExperiencesContent Publishing If these apps are not on their most recent version, we recommend upgrading them (regardless of whether the specific issue they reported is fixed in one of the PRBs/STRYs included in the most recent version or not), as being on the latest version might prevent other known issues. Pro Tip: Upgrading Employee Center Pro (if installed) would upgrade all the above apps as dependencies. The quickest way to check which version is currently being used is to navigate to the Script Includes list and search for "Application Name starts with Employee": and then open the Employee Center record in a new tab and look for the Version value: Note that the above list view would also quickly tell you whether Employee Center Pro is installed or not (EC Pro is a separate app from Employee Center, see Employee Service Center is moving to the ServiceNow Store in Rome for more details). The advantage of using the Widgets or Script Includes lists is that you can also quickly check for any customisation. More on that later on... The most recent version of the app can be found on the ServiceNow Store: You can also find the latest released versions of the Employee Center app in the documentation: Store - Employee Service Management release notes If the issue can be recreated in sub-prod, try upgrading these apps and retest. Are all the Employee Center apps on the same version? It is important to double-check whether all the Employee Center apps are on the same version; if they are not, unexpected behaviours can arise. Navigate to the System Definition > Plugins and review the current version of all of these apps (if they are active): Employee CenterEmployee Center CoreEmployee Center ProContent PublishingContent Experiences Check RCAs Most of the items part of Employee Center (i.e. Widgets and Script Includes) have their Caller Access set to "Caller Restriction", which means Caller Restricted Access (RCA) records with the items as the source and/or the target might exist. If any of the related RCA records are NOT in Allowed status, unexpected behaviour can occur. Navigate to System Administration > Application Restricted Caller Access > and filter for "Status NOT Allowed": https://instance_name.service-now.com/sys_restricted_caller_access_list.do?sysparm_query=status!%3D2&sysparm_view= Review this list of RCAs, focusing on those related to the Widget/Script Include/ACL currently being investigated. In sub-prod, you MIGHT move them to the Allowed state to rule them out. This can be done one by one or in bulk by running the below script in the Global scope from Scripts Background: var gr = new GlideRecord('sys_restricted_caller_access');gr.addQuery('status', '!=', 2);gr.query();while (gr.next()) { gr.status = 2; gr.update();} ALWAYS ask for approval before updating them, unless you are ready to manually move them back to their original status after your troubleshooting efforts. DO NOT delete RCA records. Deleting RCAs might cause even more issues, as they are needed for items in different scopes to access each other. Impersonation Most of the functionality of the Employee Center depends on the current persona. ALWAYS impersonate a user when following the Steps to Reproduce. Most of the time, the 'Maint' user does not have the correct access rights. Note that different personas can see different information, so impersonating different users can display different data. If troubleshooting in sub-prod, try granting the admin role to the affected user and retest. If the issue does not occur, it's most likely caused by incorrect access rights, with the usual suspect being ACLs and Query Business Rules. Remove the admin role from the user as soon as possible after testing. Which widget is being used? If you are impersonating a user with the admin role, you can click Control + Right-Click and then select the Show Widget Customizations option from the contextual menu: Any customized widget would then be highlighted in red: If you are impersonating a user without the admin role, follow these steps: 1. Open the Browser Console / Developer Tools. 2. If not already selected, click on the "Select an element" option. 3. Select the element you are interested in. Try to select the innermost one, if possible. 4. In the Elements section of the Developer Tools, slowly scroll up until you find a <div> element with the widget="widget" parameter, i.e.: <div class="v34a149f0531130107eb7ddeeff7b1271 ng-scope" data="data" options="options" widget="widget" server="server" sn-atf-area="Todos Approval Actions"> The "class" parameter contains the sys_id of the widget being rendered, prefixed by the letter "v". In this example, the widget sys_id = 34a149f0531130107eb7ddeeff7b1271 The "sn-atf-area" parameter contains the "name" of the widget. In this example: "Todos Approval Actions". Slowly scrolling up or down the "Elements" section on the Developer Tools and looking for any other <div> element with the "widget" parameter would show which other widgets are being displayed. This is extremely useful to make sure you are troubleshooting the correct widget, since not all widgets are listed in the Portal Page directly and could be called directly from within the code of other widgets. For example, scrolling up from the above element, you can see how the Todos Approval Actions is embedded within the Todos Approval widget, which in turn is embedded within the To-dos task Line Item widget: Page Route Maps While reviewing the widgets being used, you might notice that they do not match the widgets included on the page shown in the URL. For example, in the following URL, the page defined in the id parameter is ticket: https://instance_name.service-now.com/esc?sys_id=a9e9c33dc61122760072455df62663d2&view=sp&id=ticket&table=change_request As per the above screenshot, the widgets being used are Standard Ticket Tab and Standard Ticket Conversations. However, when opening the Portal Page definition for the ticket page, the widgets it includes are different: This is because the Standard Ticket Page Route for ESC Page Route Map routes from the ticket page to the standard_ticket page. So, the widgets being used are those on the standard_ticket page. It's always good to double-check whether any Page Route Map is in place for the current page and portal, to avoid confusion: https://instance_name.service-now.com/sp_page_route_map_list.do Sometimes it is also useful to try activating/deactivating a specific Page Route Map to narrow down an issue to a particular widget and/or provide a workaround. Using the above example, let's assume that the Attachments tab is not visible when navigating to the above URL. If you deactivate the existing Page Route Map and the tab is visible, you can narrow the issue down to a widget on the standard_ticket page rather than on the ticket page. At the same time, you can deactivate the Page Route Map as a temporary workaround while further investigations are underway. Themes and CSS When troubleshooting a UI issue (i.e. accessibility issues, overlapping text, text colors, etc.), the first thing to do is to check if the /esc portal definition is using the out-of-box (OOB) Theme. Navigate to Service Portal > Portals > Employee Center and check whether the EC Theme is being used. If not, temporarily set the Portal's Theme to the OOB EC Theme and retest. It's also a good idea to double-check whether the EC Theme itself or its CSS Includes / JS Includes have been customized or not. If anything is customized, try reverting each item to OOB and retesting. Check if the issue happens on a different portal If the issue is on a page that other portals can use, always try opening the same page in other portals. For example, if the reported issue is on /esc?id=kb_article try replacing it with /sp?id=kb_article or /kb?id=kb_article. If the issue persists on other portals, it is most likely specific to the page itself or any of its widgets, which might be part of a different plugin. In such a case, the issue is not specific to ESC. NOTE: Double-check any Page Route Map for a specific portal! Check for Widget Customizations, Dependencies, Angular Providers, and Angular ng-templates If a widget has been customized or is completely custom (perhaps as a clone of an OOB one) make sure to compare its Dependencies, Angular Providers, and Angular ng-templates related lists as well, as any of them might have also been customized or, in the case of clone widgets, might be missing altogether on the cloned one. Suppose you are inspecting the HTML on the page, and you cannot find a specific section of code in the Body HTML template of the widget itself. In that case, chances are that it's defined in one of the related Angular Providers and Angular ng-templates instead. How to debug the Widgets' Server Script code The code in the Server Script of a widget is where the majority of the logic is defined, and it's what usually gets logged in the error messages displayed on the portal. The easiest way to debug it is to add some gs.info statements printing out the variable you are interested in. NOTE: do not use gs.print or gs.log as they don't work in scoped apps. NOTE: After adding the debug statements, review the RCAs and make sure to move back to the Allowed status any RCAs that might have been invalidated. Common Errors These are some of the most common errors reported on the Employee Center, usually after an upgrade. Error: Cannot find function <function_name> in object One of the most common errors reported after an upgrade is Cannot find function <function_name> in object when navigating to some of the pages on the /esc portal: In the above example, the errors are: Server JavaScript error Cannot find function _getDueDateWarning in object [object Object].Line number 66 (sp_widget.bdc676957317130030f331d7caf6a74d.script)Script source code logged to browser consoleFailing widget: 'HRM Todos Summary' (bdc676957317130030f331d7caf6a74d) The errors point to line 66 of the Server Script section of Widget HRM Todos Summary (sys_id=bdc676957317130030f331d7caf6a74d). This is the starting point for further troubleshooting. Line 66 is: data.todosToShow = util.getMyTodos(data.queryLimit, [], input.includeTodo,undefined,undefined,input.selectedFiltersFromTodoPage.finalFilterConditions,input.selectedFiltersFromTodoPage.applyFilters); where util is defined a few lines above, at line 30: var util = new sn_hr_sp.todoPageUtils(); You can see from the above that the function mentioned in the error message (_getDueDateWarning) is not being called directly by the widget. The widget calls the function getMyTodos in Script Include todoPageUtils, so the next step is to check this Script Include. The first thing to do is to check whether the Script Include has been customized. Usually, the function mentioned in the error message is a new one introduced in the latest version of the Script Include; if the SI was customized, the function would not be defined. Reverting the Script Include to OOB should solve this issue. NOTE: Sometimes the function mentioned in the error message is not defined in the Script Include called by the widget (in this example todoPageUtils, but rather it's part of another Script Include that might be called within todoPageUtils (i.e. hr_PortalUtil). The quickest way to find where a specific function is defined (if you have access to an OOB instance on the latest version) is to search the Script Includes [sys_script_include] for Keywords = <function_name>, i.e: https://instance_name.service-now.com/sys_script_include_list.do?sysparm_query=123TEXTQUERY321%3D_getDueDateWarning This search should not be performed on a customer's instance, as if the Script Include has been customized, the function might NOT exist at all. Error: Execute operation on <item_type> <item_name> from scope 'Employee Center' was denied Another very common error is Execute operation on <item_type> <item_name> from scope 'Employee Center' was denied. The application 'Employee Center' must declare a cross scope access privilege. Please contact the application admin to update their access requests. when navigating to some of the pages on the /esc portal: In the above example, the errors are: Execute operation on script include 'todoPageUtils' from scope 'Employee Center' was denied. The application 'Employee Center' must declare a cross scope access privilege. Please contact the application admin to update their access requests.Server JavaScript error undefined is not a function.Line number 21 (sp_widget.d0009941eb103010ed7966d6475228c1.script)Script source code logged to browser consoleFailing widget: 'Employee Center Header' (d0009941eb103010ed7966d6475228c1) While it's possible to follow the same steps as the previous example and start from the widget, these kinds of Error messages are very self-explanatory: one or more RCAs with Operation = Execute API and target = todoPageUtils is not in Allowed status. Either it is in Invalidated or Requested status OR it does not exist on the instance. To solve this issue, follow the steps mentioned in the Check RCAs section above. Error: Failing widget: 'Relevant for you' (6cc836d0dbf700500c209493db961914) The following errors can be seen when navigating to the Employee Center homepage: Server JavaScript error undefined is not a function.Line number 78 (sys_script_include.35dfe52797e50110ecc47e0e6253af29.script)Script source code logged to browser consoleFailing widget: 'Relevant for you' (6cc836d0dbf700500c209493db961914) These errors are caused by a mismatch between Employee Center/Employee Center Core app versions, for example, by having Employee Center and Employee Center Core on v27 while Employee Center Pro is still on v23.