Hide/Display form sections based on user group

Harish Kota
Kilo Sage

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.

1 REPLY 1

Vijay Talupula
Tera Guru
Tera Guru

This is really helpful, thank you.