- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2019 09:50 AM
Hello,
I want to hide the "Export" Option in the UI context menu for table "sys_user" and want to keep it for admin users only. I know the option of Export exists user System UI-> UI context Menu , but what condition can I put there so that it is only applied to the sys_user tbale and only the Export option is available to only admin in the user table ?
Please help
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- 3,550 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2019 11:00 AM
You can open Context Menu [sys_ui_context_menu] table in menu System UI > UI Context Menus, filter by Name equal to Export and open the definition of Export menu.
By default the Condition of Export menu is
!ListProperties.isRelatedList() && !ListProperties.isRefList()
I suggest you to change the condition to
!ListProperties.isRelatedList() && !ListProperties.isRefList() && (ListProperties.getTable() != "sys_user" || gs.hasRole("admin"))
You should receive results, which you need: "Export" menu will be displayed in Users table only for admins. Other tables will hold "Export" menu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2021 06:21 AM
Hi Oleg,
It works fine for list table context menu Export, but it does not work in form context menu Export. please suggest.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2021 07:10 AM
Export menu of a form will be added by UI macro context_form_header, which can be modified to be available not for non-admins. See KB0852765 for more details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2021 11:46 AM
Hi Oleg,
Thanks for your quick response. Actually I need to hide that Export option from "form context menu" for specific application, not for globally. please suggest.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2021 12:53 PM
Hi Pradeep,
I'm not sure in which scenarios you need to hide context menu "Export". I guess, you want to hide it in some specific forms of some tables. In the case, you can create onLoad Client Script, where you uncheck "Isolate script" to allow access to global window object. You can use the following code of the client script:
function onLoad () {
if (window != null && window.gcm != null) {
window.gcm.getMenu()
.querySelector("div[item_id=context_exportmenu]")
.style.display = "none";
}
}
The global variable gcm (property of window) will be set by UI macro context_form_header. So you can use it to access Export submenu. The above code hide the menu item. Is it what you need?
Regards
Oleg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2021 11:00 PM
Hi Oleg,
Thank you. Yes, that's only I meant, I want to hide it in some specific forms of some tables.
But that above code is not working for me(window object giving null). I created Onload function in client script.
and if I do it by UI macro(context_form_header) then it working but for global, not only specific scoped application.
please suggest.
Thanks