Showing approvals in SOW tier 2 view

Paul Ciarfella
Tera Guru

Are approvals visible in the SOW tier 2 view OOB?

 

I would like to show outstanding approvals assigned to the L2/L3 agent in the Service Operations Workspace tier 2 view, like it shows in the /now/nav/ui/home page.

 

I'm curious if its OOB before I try to make a variant.  I don't see any options for it in the configuration.

 

1 REPLY 1

aircarewwilson
Tera Contributor

Paul, This is something I'm working on right now. There's another post somewhere on here for doing the normal tier 1 homepage, and this is essentially the same thing. It's not OOB necessarily, but it is a configuration of the SOW workspace. 

 

You will need to go to the UX Client Script Includes (sys_ux_client_script_include) table and modify the "SOWLandingPageTier2Utils" script. This extends "SOWLandingPageTier2UtilsSNC". A new object needs to be created for the "approvals" tile configuration, something like this: 

 

{
                    "id": "approvalAssigned",
                    "tableName": "sysapproval_approver",
                    "tableDisplayValue": "Approvals",
                    "myWorkQuery": "sys_id=javascript:new ApprovalDelegationUtil().getOnlyDelegatedApprovals()^ORapproverDYNAMIC90d1921e5f510100a9ad2572f2b477fe^state=requested",
                    "myTeamQuery": "approverDYNAMIC519567229323b1109666f2384dba10b2^state=requested",
                    "listView": mode == "your_work" ? "sow_landing_page_assigned" : "sow_landing_page",
                    "header": mode == 'your_work' ? await helpers.translate("Your Approvals") : await helpers.translate("Your Team Approvals"),
                    "groupByField": "state",
                    "evamId": "336c9b78e12130106d717fa153e0ffc4",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                }

 

Most of it should be fairly self-explanatory other than the EVAM ID if you're familiar with scripting in SN. myWorkQuery and myTeamQuery are encoded queries for the approval table. The myWorkQuery here includes delegate approvals and approvals for "is (dynamic) Me". The myTeamQuery uses "is (dynamic) one of my reports". 

 

The "evamId" sys_id is referencing the EVAM Definitions (sys_ux_composite_data) table. The easiest way to do this is using the OOB "Next Experience Landing Page - My Approvals Dataset" definition. You can also create your own. https://docs.servicenow.com/bundle/washingtondc-servicenow-platform/page/administer/evam/task/define...

 

 

The whole "SOWLandingPageTier2Utils" script should look something like this: 

 

function include({ imports }) {

    let SOWLandingPageTier2UtilsSNC = imports['sn_sow_itsm_common.SOWLandingPageTier2UtilsSNC']();
    class SOWLandingPageTier2Utils extends SOWLandingPageTier2UtilsSNC {
        static async getVisualizationConfig(helpers, mode, conditionalRecordCount) {
            const visualizationConfig = [
                {
                    "id": "incidentAssigned",
                    "tableName": "incident",
                    "tableDisplayValue": "Incident",
                    "myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
                    "myTeamQuery": "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
                    "header": mode == 'your_work' ? await helpers.translate("Incidents assigned to you") : await helpers.translate("Incidents assigned to your team"),
                    "groupByField": "state",
                    "evamId": "01a404e8b7203010e69dbc16de11a93f",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                },
                {
                    "id": "problemsAssigned",
                    "tableName": "problem",
                    "tableDisplayValue": "Problem",
                    "myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
                    "myTeamQuery": "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
                    "header": mode == 'your_work' ? await helpers.translate("Problems assigned to you") : await helpers.translate("Problems assigned to your team"),
                    "groupByField": "state",
                    "evamId": "5f0697b8f49bc510f8773ad5bd0ae292",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                },
                {
                    "id": "changesAssigned",
                    "tableName": "change_request",
                    "tableDisplayValue": "Change Request",
                    "myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe",
                    "myTeamQuery": "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744",
                    "header": mode == 'your_work' ? await helpers.translate("Changes assigned to you") : await helpers.translate("Changes assigned to your team"),
                    "groupByField": "state",
                    "evamId": "e1f06c4194130110f87765e94545da91",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                },
                {
                    "id": "taskAssigned",
                    "tableName": "task",
                    "tableDisplayValue": "Task",
                    "myWorkQuery": "active=true^assigned_toDYNAMIC90d1921e5f510100a9ad2572f2b477fe^sys_class_name=incident_task^ORsys_class_name=problem_task^ORsys_class_name=change_task^ORsys_class_name=sc_task",
                    "myTeamQuery": "active=true^assignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744^sys_class_name=incident_task^ORsys_class_name=problem_task^ORsys_class_name=change_task^ORsys_class_name=sc_task",
                    "header": mode == 'your_work' ? await helpers.translate("Tasks assigned to you") : await helpers.translate("Tasks assigned to your team"),
                    "groupByField": "sys_class_name",
                    "evamId": "615d205d94df0110f87765e94545da03",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                },
                {
                    "id": "approvalAssigned",
                    "tableName": "sysapproval_approver",
                    "tableDisplayValue": "Approvals",
                    "myWorkQuery": "sys_id=javascript:new ApprovalDelegationUtil().getOnlyDelegatedApprovals()^ORapproverDYNAMIC90d1921e5f510100a9ad2572f2b477fe^state=requested",
                    "myTeamQuery": "approverDYNAMIC519567229323b1109666f2384dba10b2^state=requested",
                    "listView": mode == "your_work" ? "sow_landing_page_assigned" : "sow_landing_page",
                    "header": mode == 'your_work' ? await helpers.translate("Your Approvals") : await helpers.translate("Your Team Approvals"),
                    "groupByField": "state",
                    "evamId": "336c9b78e12130106d717fa153e0ffc4",
                    "updated_on": "^ORDERBYDESCsys_updated_on",
                }];

            if (mode == 'your_work' && conditionalRecordCount > 0) {
                const conditionalConfig = await this.getConditionalVisualizationConfig(helpers);
                visualizationConfig.push(conditionalConfig);
            }

            return visualizationConfig;
        }
    }

    return SOWLandingPageTier2Utils;
}