Not able to show header menu on custom service portal

ujjwala_678
Tera Contributor

Hello Experts,

I am currently working on custom service portal and I have received this requirement to show OOB 'approvals' header menu on customised service portal....so far I have added the menu item by navigating to the Service portal----> menus--->new.....The issue is the newly added menu item is not at all reflecting on the service portal?
On the widget record I could see there is angular dependency and they have added angular template also,

I was thinking, may I be I have to add template entry for the newly added menu item also? 

Could anyone please help me out here?

Any kind of help is highly appreciated!

Thank you in advance,

1 ACCEPTED SOLUTION

Do like this

Create a Script include

Narsing1_0-1704592296468.png

var approvalUtils = Class.create();
approvalUtils.prototype = {
    initialize: function() {},
    checkApprovals: function() {
        var grApproval = new GlideRecord('sysapproval_approver');
        grApproval.addQuery('approver', '=', gs.getUserID());
        grApproval.addQuery('state', '=', 'requested');
        grApproval.query();
        return grApproval.hasNext();
    },
    type: 'approvalUtils'
};

Create a duplicate menu item "Approvals" like this

Narsing1_1-1704592400839.png

Configure this menu item like this

Narsing1_2-1704592451344.png

 

This will show you when you don't have any approvals. The other one will show when it has approvals.

 

Please mark my answer correct and helpful if it works.

 

Thanks,

Narsing

View solution in original post

10 REPLIES 10

sumanta pal
Kilo Guru

Sure, to show the OOB 'approvals' header menu on a customised service portal, you can follow these steps: 1. Navigate to Service Portal > Menus in your ServiceNow instance. 2. Click on the menu where you want to add the 'approvals' item. 3. Click on 'New' to create a new menu item. 4. In the 'Type' field, select 'Module'. 5. In the 'Module' field, select 'Approvals'. 6. Fill in the other fields as necessary, such as 'Order' for the position of the menu item, and 'Roles' if you want to restrict the visibility of the menu item. 7. Click on 'Submit' to save the new menu item. Please note that the 'Approvals' module should be available in the 'Module' field if it's an OOB module. If it's not available, it might be a custom module, in which case you would need to create a URL redirect menu item instead, with the URL pointing to the 'Approvals' page. Here is a sample code for creating a menu item: javascript var gr = new GlideRecord('sp_menu_item'); gr.initialize(); gr.sp_menu = 'your_menu_sys_id'; // replace with your menu's sys_id gr.type = 'module'; gr.module = 'sys_id_of_approvals_module'; // replace with the sys_id of the 'Approvals' module gr.order = 100; // replace with the desired order gr.insert(); Replace 'your_menu_sys_id' with the sys_id of your menu, and 'sys_id_of_approvals_module' with the sys_id of the 'Approvals' module. You can find these sys_ids by right-clicking on the respective records and selecting 'Copy sys_id'.

service portal

 

Hi @sumanta pal 

Thank you for your inputs on this...My concern is 

OOB approvals header will appear only when you have approvals pending

I want it should be visible all the time....even if the users don't have any approvals pending from their end they should be able to see approvals header menu....Is there any way I can achieve this?

Thank you

Hi @ujjwala_678 

 

Any specific use case to show approval menu if there is  not approval. You can educate to the users on this.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Do like this

Create a Script include

Narsing1_0-1704592296468.png

var approvalUtils = Class.create();
approvalUtils.prototype = {
    initialize: function() {},
    checkApprovals: function() {
        var grApproval = new GlideRecord('sysapproval_approver');
        grApproval.addQuery('approver', '=', gs.getUserID());
        grApproval.addQuery('state', '=', 'requested');
        grApproval.query();
        return grApproval.hasNext();
    },
    type: 'approvalUtils'
};

Create a duplicate menu item "Approvals" like this

Narsing1_1-1704592400839.png

Configure this menu item like this

Narsing1_2-1704592451344.png

 

This will show you when you don't have any approvals. The other one will show when it has approvals.

 

Please mark my answer correct and helpful if it works.

 

Thanks,

Narsing