Filter dropdown field by users group membership

Good day,
I have a simple dropdown field with some choice in it (A,B,C)
On open form a would like to filter this dropdown on depending user membership.(sharepoint group or active directory security group)
For example if user01 open form and belong to group IT - show only A,B,C in dropdown
If user02 belong to group Admins - show in dropdown - B
For rest users show A,B

Hello @ixxxl,

You can check if a user is a member of a certain group using PnPjs and then set the values of the dropdown field using the code:

				//var groups = [];
                //Check if the user is a member of the desired groups and add them to the array
				var vb=false;
				for (var i = 0; i < groupsData.length; i++) {
					if(groupsData[i].Title == 'Site Owners') {
						var datasource = [ 'A', 'B']

					else if(groupsData[i].Title == 'Site Members'){
                        var datasource = [ 'A', 'C']


I was trying but some error


I tried like this and it works, some of previos code and your code
function Line() {

    // get all groups the current user belongs to
    var userId = _spPageContextInfo.userId;
    var userGroups = [];
        for (var i = 0; i < groupsData.length; i++) {

             //check if the user is a member of Managers user group
        if (userGroups.indexOf('SupervizoriIT') >= 0) {
            //Show grid container
            var datasource = ['IT', 'Business', 'Depozit IT'];
        } else {
            var datasource = ['IT', 'Business']
            alert(' NO group')
        if (datasource) {

fd.spRendered(function() {

      //Hiding the grid containig fields available to managers only

    //call function on form load

Now i use SharePoint groups.
But if i would like to setup with Active Directory security groups , how can i verify user membership in security active directory group?

Powershell script: may be something i can try in javascript on form load?
$users = "TestUser1","TestUser2"
$group = "Domain Admins"
$members = Get-ADGroupMember -Identity $group -Recursive | Select -ExpandProperty Name
ForEach ($user in $users) {
If ($members -contains $user) {
Write-Host "$user exists in the group"
} Else {
Write-Host "$user not exists in the group"

@mnikitina , @Nikita_Kurguzov
Any suggestions, please ?

Hello @ixxxl,

I'm sorry, I've missed your post.

You can create separate forms for different user groups and route between them based on SharePoint security groups.

Ok with Sharepoint group is clarified, thank you.
But with security Active directory? Can i check if a user is from domain\group1 (security group AD)


SharePoint supports Sharepoint Groups only. But SharePoint groups are synchronized with Azure AD profiles.

1 Like

Thank you, I have active directory on prem, and security groups are only as a groups, you can't see people in group.