Hi anonymous user ,
I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.
By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:
Issue Symptom:
While creating Item Graph query throws an error when PersonOrGroup entry I add in a item AdditionalData's Dictionary object
Current status:
It's resolved by following code
Using Server Object model:
using Microsoft.SharePoint;
SPSite site = new SPSite("SiteName");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["ListName"];
string testName = "Manish Loke"; //use display name instead of login name
if (testName != "") {
SPUser userTest = web.EnsureUser(testName);
testName = userTest.ID.ToString() + ";#" + userTest.LoginName.ToString();
SPItem item;
item["ColumnName"] = testName;
item.Update();
}
Using Client object model:
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
ClientContext context = new ClientContext("SiteName");
List list = context.Web.Lists.GetByTitle("ListName");
ListItem item;
context.Load(list);
context.ExecuteQuery();
string testName = "Manish Loke"; //use display name instead of login name
if (testName != "") {
User userTest = context.Web.EnsureUser(testName);
context.Load(userTest);
context.ExecuteQuery();
testName = userTest.Id.ToString() + ";#" + userTest.LoginName.ToString();
ListItem item;
item["ColumnName"] = testName;
item.Update();
context.ExecuteQuery();
}
You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!