question

NerobovAndrey-7511 avatar image
0 Votes"
NerobovAndrey-7511 asked ·

The property or field has not been initialized. It has not been requested or the request has not been executed

Hello!
I sometimes have a problem wnen I work with CSOM for SharePoint Online.
I make this request :
var list = context.Web.Lists.GetById(listid);
item = list.GetItemById(id);
context.Load(item);
context.ExecuteQueryRetry();
context.Load(item, x => x, x => x.HasUniqueRoleAssignments, x => x.Id, x => x.ContentType.Id,
x => x.RoleAssignments, x => x.RoleAssignments.Include(y => y.RoleDefinitionBindings, y => y.PrincipalId));
context.ExecuteQueryRetry();
After that I try get LookupId :
((FieldLookupValue)item[TaskList.Expertise]).LookupId;
and I catch the 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. Stack: at Microsoft.SharePoint.Client.ListItem.GetFieldValue(String fieldName)
I don't understand, why doesn't this error happen all the time?It happens about twice a week.
I use Microsoft.SharePoint.Client, Version=16.1.0.0 and OfficeDevPnP.Core, Version=3.20.2004.0
Thanks!

office-sharepoint-online
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AmosWu-MSFT avatar image
0 Votes"
AmosWu-MSFT answered ·

The item has been loaded in the clientContext, and this problem should not occur.
I test with SharePoint.Client, Version=16.1.0.0 and OfficeDevPnP.Core, Version=3.26.2010.0. And I do not reproduce your issue.
77517-image.png


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


image.png (26.1 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

NerobovAndrey-7511 avatar image
0 Votes"
NerobovAndrey-7511 answered ·

@AmosWu-MSFT Thank! I don't reproduce too.This error occurs in runtime only and it happens about twice a week. This situations is critical for me, because error occurs in big service. Service works for many people,but all requests are made by one service account. Maybe there are restrictions on the number of requests from one account?

· 2 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This error only occurs once every two weeks or will it be reported multiple times?

0 Votes 0 ·

it occurs several times a week, sometimes more than 2.On the screenshot of the error for the last week 78185-image.png


0 Votes 0 ·
image.png (18.2 KiB)
NerobovAndrey-7511 avatar image
0 Votes"
NerobovAndrey-7511 answered ·

@AmosWu-MSFT Do you have a source code of ExecuteQueryRetry()?

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

No, I do not have the source code. You can try to decompile the DLL file.
For this issue, I suggest you submit a ticket in the admin center, so our engineers could help you check if there are some limitations of SharePoint.

1 Vote 1 ·