Version field sort order not working properly
-
11-10-2020 - |
Pergunta
The problem
I have a document library with versioning, and I am tweaking the view through the UI.
It appears that, right ootb, when we sort by Version
it doesn't really sort properly, as it appears to consider "11"
like a string and not like the interger 11
.
Sounds overkill if I am to create a new, calculated column just for this.
From the query string, I can see that the field being sorted is _UIVersionString
so I guess I shouldn't be surprised.
SortField=_UIVersionString-SortDir=Asc
Anyone else experienced this and has any tips?
Similar threads
How can I add the UIVersion (integer) field to a view?
Screenshot
Update
I might just be able to update the view through CSOM to make it use "UI Version" field instead of "Version" (Title Name)
Solução
Much to my dissatisfaction, the cleanliest solution I could find was to create a new calculated column, retrieving the integer
value of the Version
field.
Create a new calculated column using the formula
=VALUE(Version)
e.g.
Apparently, the Version
field - also known by it's StaticName _UIVersionString
- is of type Text/String
, therefore cannot be sorted properly.
There is a field _UIVersion
that can in fact be used to sort by version perfectly, however the contents of this field are in a different format, as shown below (something like 512 for each major version). These hidden fields can be added by tweaking the view with CSOM for example.
A quick "workaround" for getting this (manually) would be to replace _UIVersionString
in the URL by _UIVersion
and use Asc
or Desc
for sorting order.
SortField%3D_UIVersion-SortDir%3DAsc