-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Category
- Bug
Describe the bug
There is a mismatch between the RenderListDataAsStreamAsync response and the parsed FieldUserValue object in pnp core when using UserMulti.
List data: we are showing users "Account" as "lookup value" instead the Name

PnP Core FieldUserValue vs RenderListDataAsStreamAsync reponse for same list item / query:

Steps to reproduce
Create a test list with a multiuser field.
In field properties, change the "Show field" to "Account" or any.
Create a list item and fill with several users.
Execute a query to get the list item and verify that the lookup value of the field could not be accessed.
await list.LoadListDataAsStreamAsync(new RenderListDataOptions(){
ViewXml = "<View><RowLimit>1</RowLimit></View>",
RenderOptions = RenderListDataOptionsFlags.ListData
}
Expected behavior
The lookup value ("Account") should be accesible from the FieldUserValue.LookupValue property as it's returned in the response json.
Additional context
It's really strange that RenderListDataAsStreamAsync api call renders a different object for User and UserMulti

The lookup value for "User" is rendered in the "title" field, but for "UserMulti" there is a "value" property with the lookup value instead.
I'm sure that it could be fixed around this method:
| internal override IFieldValue FromListDataAsStream(Dictionary<string, string> properties) |
By adding handling for "value" property (if available) like this:
if (properties.ContainsKey("value")) { LookupValue = properties["value"]; }
PD: probably it's also a good idea to check if the object that is being parsed by the method has "value" property, if not set LookupValue to the title (for 'User' field) i think this would be something expected from a SHP developer perspective.