1

I've done a small program to export data from Project Server to Sharepoint Server 2016, as the number of exporter field is dynamic, I had to use sql db (because CSOM doesn't allow to use other baseline than baseline 0)

So now it's pretty finish, I just have a last issue to fix In my SQL DB, I have some person which are extracted as a string, if I tried to copy this value via my program in a field Person, I have an error message, so I'd like to know how can I pass transform this string to a person?

Thank you for your help

1 Answer 1

0

Here is the code snippet:

using Microsoft.SharePoint;  
using Microsoft.SharePoint.Client;  
ClientContext context = new ClientContext("SiteNameXXX");  
List list = context.Web.Lists.GetByTitle("ListNameXXX");  
ListItem item;  
context.Load(list);  
context.ExecuteQuery();  
string name = "GET NAME FROM SQL";   
if (name != "") {  
    User userTest = context.Web.EnsureUser(testName);  
    context.Load(userTest);  
    context.ExecuteQuery();  
    testName = userTest.Id.ToString() + ";#" + userTest.LoginName.ToString();  
    ListItem item;  
    item["PeoplePickerField"] = name;  
    item.Update();  
    context.ExecuteQuery();  
}  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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