How to pass dynamic argument in a function being called in condition field in Service Portal Menu It
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 12:54 PM
I am using a function to dynamically display a menu item in Service Portal as shown below:
javascript:x_20949_ppt.permissionToAccessMenuItem('8b5ddfd21b4e4110796da9b5624bcbf4')==true;
The argument being passed is the sys_id of the current menu item, and it works fine. But I want to make it dynamic by using dynamic arguments as given below, and they do not work:
javascript:x_20949_ppt.permissionToAccessMenuItem(g_form.getValue('sys_id'))==true;
javascript:x_20949_ppt.permissionToAccessMenuItem(g_form.getUniqueValue('sys_id'))==true;
javascript:x_20949_ppt.permissionToAccessMenuItem(current.sys_id)==true;
Any suggestions or solutions will help. Please refer to the screenshot below:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2023 11:02 PM
Hi,
Can you please explain your use case?
In which condition you want to show it?
How is your sys_id going to be dynamic? To which record it refers on Portal?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:07 AM
Hi Anil,
Thank you for your enquiry and offer to help. I apologize for not being able to disclose the exact condition due to the custom scope. However, the condition is applied dynamically by reading from a custom table in the scoped application.
In the custom function (script include) that I am using, I am passing the Sys ID of the menu item for the record that is on the table ‘sp_rectangle_menu_item’ as the condition. The function returns true or false, which decides whether to display the menu item for a user with a permitted role or not.
If it is a simple role or roles related access, I am using it directly as the condition to validate and restrict. But there is also a string length limit for the condition field. In this case, the condition is dynamic, and hardcoding the sys_id as an argument in the function works fine but want to pass sys_id of menu item dynamically to make it generic irrespective of menu.
I hope this will help you provide a solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:01 PM
Hi,
You can pass hardcoded sys_id because it is not going to change even if you move Menu Item to another instance. The function your are calling from Condition field is limited to to that particular menu item, so it will need sys_id of that particular menu item record which is not going to change.
If you don't want to hardcode in condition then you can use system property and use it your condition like below:
javascript: new x_20949_ppt.permissionToAccessMenuItem(gs.getProperty('MenuItemPropertyName'))==true;
Create new system property "MenuItemPropertyName" and save the sys_id of your menu item as value.
Thanks
Anil Lande