Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have following code on infopath form. All the column gets updated in the target list except for the people column. The verifiedBy is not updating the column in SP List. (In the list I have to to display Name). I even tried DisplayName instead of AccountId.

Can anyone please tell me what I am doing wrong. Thanks in advance.

item["LoadDate"] = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpLoad/my:fldLoadDate", NamespaceManager).Value;
item["EndDate"] = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpLoad/my:fldEndDate", NamespaceManager).Value;
item["checkRequired"] = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpLoad/my:fldcRequired", NamespaceManager).Value;                                                                                                         
item["VerifiedBy"] = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value;
share|improve this question
    
I modified verifiedBy like below but still not working. item["VerifiedBy"] = web.EnsureUser(MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/m‌​y:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value); –  Joe Yee Sep 11 '12 at 18:13
    
low in the hole, this code is now working. item["VerifiedBy"] = web.EnsureUser(MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/m‌​‌​y:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value); –  Joe Yee Sep 11 '12 at 18:54

3 Answers 3

You might need to format the InfoPath user like [id];#[username]

maybe something like...

item["VerifiedBy"] = String.Format("{0};#{1}", MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpDaa/my:CheckedBy/pc:Person", NamespaceManager).Value), MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value);

A couple resources I found this were

share|improve this answer
    
e-rock: low in the hole: this code is now working. item["VerifiedBy"] = web.EnsureUser(MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/m‌​‌​y:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value); –  Joe Yee Sep 11 '12 at 18:54

You probably need to construct the correct string in the following format: "[userid];#[displayname]", or use an SPFieldUserValue class for that.

For example:

SPUser user = web.EnsureUser(MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/m‌​‌​y:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value);
item["VerifiedBy"] = new SPFieldUserValue(web, user.ID, user.Name);

Note that you might have a permission issue with EnsureUser method, if the user is not added to the site collection.

share|improve this answer
up vote 1 down vote accepted

This worked.

item["VerifiedBy"] = web.EnsureUser(MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/m‌​‌​y:grpDaa/my:CheckedBy/pc:Person/pc:AccountId", NamespaceManager).Value);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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