Hide Grid (and embedded controls) based on Permission Group

Hi All, new to this form product and have used Nintex for year. I want to hide a sub grid and associated fields based on SharePoint permission user group.

In Nintex I would have set visible to an expression of fn-IsMemberOfGroup(Site Editors)

How do I do that here?

I see I can create a secondary form set to appear to the selected users, I will do that. If someone knows of another way please let me know!

Dear @cortese98,
Technically, you can make a request, check user’s permission group with JavaScript on the form, and based on that - hide or show field. That’s just extra work for you, plus longer loading time on the page.

Redirection based on Routing settings on the other hand is easy to configure, it runs minimal scripts on the redirection page before opening the form, and there is no way for the user to access removed fields/grid even if the user tries - these will simply be not present on the form.

We do highly recommend Routing as the more reliable, faster and easier solution in this case, but there are other methods, of course.

Hi Nikita,
Could you share how I could do the permission check with JS?

Here’s my scenario: I have a form with two content types (form 1, content type a & b). The default (content type a) is visible to all, the second (content type b) is intended just for one group.

This form (form 1) is embedded into another form (form 2) using the list/library tool in Forms. In that second form when you click “add new item” the default form shows up (content type a) - I need the second form (content type b).

Therefore, the content type selector needs to be available in form 1, content type a. I do not want this one field to be visible to everyone; just the one group. So, I need to do a permissions check and then hide that field if they are not a member. Can you help?

Here’s the script I have:

fd.spRendered(function() {
var url = _spPageContextInfo.webAbsoluteUrl +'/_api/web/currentuser/groups';
$.getJSON(url, function (data) {
    $.each(data.value, function (key, value) {
		    if (value.Id == '5') {               

And here is the error I receive on the console:

VM18798:12 Uncaught TypeError: Cannot read property '$parent' of undefined
    at Object.eval (eval at e._executeCustomJavaScript (VM18791 spform.js:38), <anonymous>:12:36)
    at Function.each (VM18791 spform.js:51)
    at Object.eval [as success] (eval at e._executeCustomJavaScript (VM18791 spform.js:38), <anonymous>:10:11)
    at u (VM18791 spform.js:61)
    at Object.fireWith [as resolveWith] (VM18791 spform.js:61)
    at r (VM18791 spform.js:61)
    at XMLHttpRequest.<anonymous> (VM18791 spform.js:61)

My Solution to this one is as below, I call the function and set the variables so I can then use again and again as required throughout my Form to Hide or disable fields based on the users Group Membership.

var isSalesGroupMember = currentUserIsMember('Sales');

// Function to Determine if Current User is Member of Sales Managment Group
function currentUserIsMember(groupName) {
	var isMember = false;
		url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getByName('"+ groupName +"')/Users?$filter=Id eq " + _spPageContextInfo.userId,
		method: "GET",
		headers: { "Accept": "application/json; odata=verbose" },
		async: false,
		success: function(data) {
			if(data.d.results[0] != undefined) {
				//User is a Member, do something or return true
				isMember = true;
	return isMember;

And then I can use the variable wherever I need along with any other checks I may need for groups.

// Function to Show Approve/Amend Sales Price Buttons if Pricing Status = Under Review & User is Member of Sales Management Group
function showApproveAmendSalesPriceButtons () {
	if ((pricingStatusOnLoad == "Under Review") && (isSalesManagementGroupMember == true)) {
	} else {

Hope it is useful for you…

Dear @mauraobenshain,

What type has a field ‘GroupMembersOnly’? It looks like you should wrap it in “ready” event handler: https://plumsail.com/docs/forms/javascript/fields.html

Also, consider please a solution suggested by @Tony_Duke.

It’s a single line of text SP field. this one is just a test - the real field is a content type selector.

Thank you @Tony_Duke - your solution works perfectly!

1 Like

Thank a lot @Tony_Duke. It is workfing fine :ok_hand::clap:

1 Like