Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem on a number column #751

Closed
1 task done
TanguyPa opened this issue Feb 4, 2022 · 3 comments
Closed
1 task done

Problem on a number column #751

TanguyPa opened this issue Feb 4, 2022 · 3 comments
Assignees
Labels
area: model 📐 Related to the core SDK models bug Something isn't working

Comments

@TanguyPa
Copy link

TanguyPa commented Feb 4, 2022

Category

  • Bug

Describe the bug

I try to read the data of an item that has a column of type "Number", when the latter is filled the right value is returned.

Except that when it is not filled, the value 0 is returned, so I can't distinguish an item with a value of 0 from an item that has no value.

I'm using LoadListDataAsStreamAsync with camlquery, the item has the content type "Document set".

Steps to reproduce

I get the items this way (filter to differentiate between doc sets and files)

string viewXml = @"<View Scope='RecursiveAll'>
										<ViewFields>
										  <FieldRef Name='MyNumberColumn' />          
                                                                                  <FieldRef Name='FileLeafRef' />                                           
                                                                                  <FieldRef Name='FileDirRef' />                                           
                                                                                  <FieldRef Name='FileRef' />            
                                                                                  <FieldRef Name='Title' />                                    
										</ViewFields>                                              
									   </View>";
// Execute the query
var output = await list.LoadListDataAsStreamAsync(new PnP.Core.Model.SharePoint.RenderListDataOptions()
{
	ViewXml = viewXml,
	RenderOptions = RenderListDataOptionsFlags.ListData
});
foreach (var item in list.Items.AsRequested())
{
	if ((string)item["ContentTypeId"] == "xxxx")
	{
		ensemblesDocsItems.Add(item);
	}
	else if ((string)item["ContentTypeId"] == "xxxx")
	{
		docsItems.Add(item);
	}

}
foreach (var ensItem in ensemblesDocsItems)
{                       
     var value = ensItem["MyNumberColumn"];
}

Expected behavior

ensItem["MyNumberColumn"] == 10 when the value is 10
ensItem["MyNumberColumn"] == 0 when the value is 0
ensItem["MyNumberColumn"] == null (or something else) when there is no value

Environment details (development & target environment)

SDK version: 1.5.0 (try 1.4.0 too)
OS: Windows 10
SDK used in: Console App
Framework: .NET 5.0
Tooling: Visual Studio 2019

@jansenbe jansenbe self-assigned this Feb 4, 2022
@jansenbe jansenbe added area: model 📐 Related to the core SDK models bug Something isn't working labels Feb 4, 2022
@jansenbe
Copy link
Contributor

jansenbe commented Feb 4, 2022

@TanguyPa , good catch. When using LoadListDataAsStreamAsync this indeed goes wrong. Fix will be checked in soon

jansenbe added a commit that referenced this issue Feb 4, 2022
…s without a value set where returned as value 0 whereas they should have been returned as null #751
@jansenbe
Copy link
Contributor

jansenbe commented Feb 4, 2022

@TanguyPa : and the fix is in. Please try again with our next nightly build that will be available as of tomorrow (you need version 1.5.51 or higher) and let us know if things work as expected. Thanks for reporting this issue!

@TanguyPa
Copy link
Author

TanguyPa commented Feb 7, 2022

Thank you, it works fine

@jansenbe jansenbe closed this as completed Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: model 📐 Related to the core SDK models bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants