I have one timer job that should add some users from one table field to one field in a sharepoint list.

In sql,its formatted as user1;user2;user3;user4

However when I see this website http://blogs.msdn.com/b/markarend/archive/2007/05/29/parsing-multi-value-fields-multichoice-lookup-user-url-rules-for-the-delimiter.aspx

It looks like I need to change the delimiter to ;#

However that site is not clear enough because it also needs an id?

Can I just use in my sql field



Use a -1 as the ID if its not know, SharePoint will attempt to look it up but will allow the storing of the data.


Firstly, you should NEVER insert SharePoint data directly in the content database.

Secondly, you SHOULD use the SharePoint Object Model to insert items into Lists.

Also, your question sounds a bit strange. You are saying you want to insert data into a SharePoint Field which is of type Multiple Users (Multivalue field). The SharePoint User Field takes exactly that... Users. Before inserting these Users (I take it you have Active DIrectory Usernames) you would have to create User Objects (Instantiate the SPUser Object using it's constructor) and pass these User objects into the Multivalue field.

THe code sample for the above can be found here: http://exxlence.com/2009/02/08/simplify-getting-and-setting-fields-of-type-spfielduser-spfieldurl-and-spfieldlookup-using-extension-methods/

The important part on that page is this part where you Set the Multivalued User/Person field:

public static void SetFieldValueUser(this SPListItem item,
  string fieldName, IEnumerable principals)
    if (item != null)
        SPFieldUserValueCollection fieldValues =
          new SPFieldUserValueCollection();

        foreach (SPPrincipal principal in principals)
              new SPFieldUserValue(
                item.Web, principal.ID, principal.Name));
        item[fieldName] = fieldValues;
  • I am not inserting data directly into the content database, I am syncing a sharepoint list with a external source (sql table), Oct 7 '13 at 10:31
  • Ok. Well, the code above is what you can use in your timer job to update the SharePoint values.
    – Fox
    Oct 7 '13 at 10:38

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.