pnpcore: Not able to Update LookUp property

Category

  • Bug

Describe the bug

Using CSOM, It is possible to update the lookup property with a string value, which does not particularly require its lookupvalue property type.

For example item[“MetaInfo”] = “some XML values” It is possible to read back the same string value during the read. I need a way to update value in a same way on PnP.

Steps to reproduce

I tried the same on PnP, However, am not able to set the property. It neither throws an exception.

var parentList = await context.Web.Lists.GetByTitleAsync("AddTest", l => l.EnableModeration, l => l.TemplateType, l => l.EnableVersioning, l => l.Title, l => l.Fields, l => l.ContentTypes);
            var parentWeb = await context.Web.GetAsync(s => s.Language, s=>s.Url);
            var parentFields = parentList.Fields.ToList();

            List<Dictionary<string, object>> propertiesToUpdate = new List<Dictionary<string, object>>();
            var prop = new Dictionary<string, object>();
            prop.Add("Title", "My title 1");
            prop.Add("MetaInfo", "abc");
            propertiesToUpdate.Add(prop);
            var prop2 = new Dictionary<string, object>();
            prop2.Add("Title", "My title 2");
            propertiesToUpdate.Add(prop2);

            var uploadedListItems = new List<IListItem>();
            foreach (var propItem in propertiesToUpdate)
            {     
                try
                {
                    var item = await parentList.Items.AddBatchAsync(propItem);
                    uploadedListItems.Add(item);
                }
                catch(Exception ex)
                {
                }
            }
            var batchResponses = await context.ExecuteAsync(false);

            await uploadedListItems.First().LoadAsync(d => d.All);

            foreach (var batchResponse in batchResponses)
            {

            }

Expected behavior

It should have been updated with no issue

Environment details (development & target environment)

  • SDK version: [1.1.0 ]
  • OS: [Windows 10]
  • SDK used in: [ Console App ]
  • Framework: [.NET Framework v4.7.2]
  • Tooling: [Visual Studio 2019]

Additional context

Thanks for your contribution! Sharing is caring.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (13 by maintainers)

Most upvoted comments

@gopaldahal : I don’t see any other options for this edge case (there’s very few people updating the metainfo field), so are you good with closing this issue?

@gopaldahal : can you provide a fiddler trace showing how this is set using CSOM and send it to bjansen@microsoft.com. When you do a SystemUpdate() or UpdateOverwriteVersion() in PnP Core we under the covers fall back to CSOM…I want to cross check if this approach can unblock this scenario for you.

Sure. I will come to this soon.

@gopaldahal : are you good with closing this issue?

Hi @jansenbe image I did read with FieldValuesAsText but working as expected.