question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to Update LookUp property

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jansenbecommented, Aug 24, 2021

@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?

1reaction
gopaldahalcommented, Jul 29, 2021

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: LookUp Field not updating i n sharepoint list
Since you customize the lookup field's data card, you need to change its Update property. Try to set the data card's Update property:...
Read more >
The Trick to Updating Custom Lookups using the Dynamics ...
In Dynamics 365 Power Apps, when updating a custom lookup field using the Web API, you may run into an “undeclared property” error....
Read more >
Trouble updating a field of type lookup with Microsoft CRM ...
I currently have some code that uses http patch to send Microsoft CRM data via the 2016 web api. When my payload includes...
Read more >
Trigger on custom object to update lookup field from other ...
i have a custom object called Booking__c that has a lookup field called Commission_Agent__c. Booking__c is related via lookup to another custom ...
Read more >
2013 - Update Lookup Site Column
It's not possible to Edit lookup columns to deleted lists. You can use powershell to do so. Check the posts here and here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found