I'm creating a website based on what a user submits in a form
3 fields are reserved for the 3 types of default groups that you're asked for when creating a subsite manually :
- Owner
- Members
- Visitors
I noticed that these groups aren't created when creating the site via JavaScript
So I created them manually, after retrieving the field's value containing the users(requestData
is a list line and value
is the field internalName) :
SetupGroup(value, suffix)
{
var users = this.requestData.get_item(value);
var groupInfo = new SP.GroupCreationInformation();
groupInfo.set_title(this.subweb.get_title() + ' - ' + suffix);
groupInfo.set_description('Ca marche presque correctement !');
var newGroup = this.subweb.get_siteGroups().add(groupInfo);
users.forEach((user)=>{
newGroup.get_users().add(user);
});
return newGroup;
}
But the content of the field is SP.FieldUserValue
instead of SP.User
and i get the error The parameter loginName cannot be empty or bigger than 251 characters
once i try to throw a query to save this
How can I achieve it ?
Also, when the group is created, do i have to simply replace the Associated groups as such, or do I have to give the permissions to each groups myself to get the same behavior as a manually created site :
this.subweb.set_associatedVisitorGroup(this.SetupGroup('Visiteurs_x0020__x0028_Lecture_x'), 'Membres');
(SetupGroup
returns a group)