Filter dropdown field by users group membership

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:

pnp.sp.web.siteUsers.getById(_spPageContextInfo.userId).groups.get()
			.then(function(groupsData){
				//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++) {
					//s+=groupsData[i].Title+"/n";
					if(groupsData[i].Title == 'Site Owners') {
						var datasource = [ 'A', 'B']
					}

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

				}
                
                if(datasource){
				fd.field('Choice').widget.setDataSource(datasource);
                fd.field('Choice').widget.setDataSource(datasource);
                }
			});