I have a list similar to the usual Tasks Sharepoint List and I introduced the field assigned to as a multi user field like this (I have read somewhere that with Mult option should always be set to TRUE) :

<Field ID="{E942F982-C798-4095-8FD3-AF9A3A374862}" Type="UserMulti" Mult="TRUE" Name="AssignedTo" DisplayName="Assigned To" Group="My Local Group"  StaticName="AssignedTo" ShowInEditForm="TRUE" ShowInNewForm="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />

to set this field I created a control to get the users:

UserField AssignedTo = new UserField();
AssignedTo.FieldName = ActionsCommercialesManagement.Fields.AssignedTo;
AssignedTo.ID = "AssignedToID";
AssignedTo.ListId = TaskListID;

and to recuperate the introduced userS in my AssignedTo userField control I tried to do something like this but it didn't work :

newItem = MyList.AddItem();
newItem["AssignedTo"] = new SPFieldUserValueCollection(ACAssignedToID.Value.toString());

So any ideas ????


if anyone is having this problem I just solved it :

SPFieldUserValueCollection assignedUsers = new SPFieldUserValueCollection(myWeb, AssignedTo.Value.ToString());
item["AssignedTo"] = assignedUsers;

and if you want to retrive the value collection as string all you have to do is :

string spliAssignedTo =((SPFieldUserValueCollection)TaskItem["AssignedTo"]).ToString();

Hope I helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.