0

I have a list which contain 30 fields and I want to use them all inside my remote event receiver, so instead of manually loading the fields one by one, I am trying to load all the fields, I tried the below code:

var items = list.GetItems(query);
clientContext.Load(items, eachItem => eachItem.Include(
item => item.FieldValuesAsText));               
clientContext.ExecuteQuery();

and this code:

clientContext.Load(collListItem,
      items => items.Include(
          item => item.Id,
          item => item.DisplayName,
          item => item.HasUniqueRoleAssignments,
          item => item.Folder,
          item => item.File,
          item => item.ContentType
      ));
clientContext.ExecuteQuery();

but when I try to retrieve a field, I will get an error:

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

So can anyone advice on this please?

1 Answer 1

0

Try something like this:

var fieldColl = list.Fields;
clientContext.Load(fieldColl);
clientContext.ExecuteQuery();

OR

clientContext.Load(list.Fields);
clientContext.ExecuteQuery();

Reference: Retrieve all of the fields in a list

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.