I am working on developing an event receiver inside my sharepoint 2013 farm on-premises. and inside the event receiver i am trying to assign a list column to a SPGroup.
what i am trying to do is similar to the following steps using the UI:-
- Go to a list settings.
- click on the column at the list level.
- override the column to be linked to a specific group (for example Approvers) instead of All Users as defined inside the site column level.
Now here is my code inside the ER:-
SPGroup newgroup = site.RootWeb.SiteGroups[currentgroupname + " Members - " + curItemID.ToString()];
foreach (SPList splist in newSite.Lists)
{
if (splist.Title.ToLower() == "action")
{
SPFieldUser spfield = splist.Fields["ActionOwner"] as SPFieldUser;
spfield = newgroup as SPGroup;
}
}
But i am getting the following syntax error on this spfield = newgroup as SPGroup;
Cannot implicitly convert type 'Microsoft.SharePoint.SPGroup' to 'Microsoft.SharePoint.SPFieldUser'