pnpcore icon indicating copy to clipboard operation
pnpcore copied to clipboard

Properties not yet Loaded for a Files modifiedBy

Open priests123 opened this issue 6 months ago • 0 comments

Category

  • [x] Bug

Describe the bug

When trying to query properties (Id, UserPrincipalName, AadObjectId) of the ModifiedBy of a File, it fails with the following error message:

Property [X] was not yet loaded - X being the name of a property

It is intermittent too. Sometimes it has the property value and other times it doesn't.

Steps to reproduce

Below is the code I'm using:

 var item = await list.Items.GetByIdAsync(itemId, i => i.Id,
    i => i.File,
    i => i.Versions,
    i => i.FileSystemObjectType);

 var file = await item.File.GetAsync(
    f => f.TimeLastModified,
    f => f.Name,
    f => f.CheckOutType,
    f => f.ModifiedBy.QueryProperties(u => u.Id, u => u.AadObjectId, u => u.Mail, u => u.UserPrincipalName));

var modifiedById = file.ModifiedBy.Id // <-- Fails on this line

Expected behavior

After getting the file, the properties on ModifiedBy should be available

Environment details (development & target environment)

  • SDK version: 1.12.0
  • SDK used in: Azure hosted Web Job
  • Framework: .NET v8

priests123 avatar Aug 28 '24 14:08 priests123