Hide/Display form sections based on user group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2022 10:52 AM
Hide/Display form sections based on the user group:
Use script Include and client scripts to achieve this requirement: below script is created for the alm_hardware table
for example: sections should display only a specific group
Script Include:
var getGroupDetails = Class.create();
getGroupDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserMembership: function() {
if (gs.getUser().isMemberOf('sys_id')) //sys_id of the group
return "hide";
else return "no-hide";
},
type: 'getGroupDetails'
});
Client Script:
function onLoad() {
var assetGA = new GlideAjax("getGroupDetails");
assetGA.addParam("sysparm_name", 'getUserMembership');
assetGA.getXML(assetSectionDisplayResponse);
function assetSectionDisplayResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'hide') {
g_form.setSectionDisplay('section_name', false); //section name
g_form.setSectionDisplay('section_name', false); //section name
}
}
}
This will helpful for Asset Management Module.
If you have any requirements such as that, please use the above code to achieve your requirement.
Please Like as Helpful if this helps with your Requirement.
- 591 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2022 10:56 AM
This is really helpful, thank you.