Start a new topic

Using the path language to get the latest version of an item

To get the latest version of an item in SystemWeaver using a path query, you can do one of the following, depending on the SW client version that you are using.

1. Using any SW client version

Path query:

AllVersions[VersionNumber.ToInteger = AllVersions.Select(VersionNumber).Max]

Item

Description

AllVersions

Returns all versions of an item.

[]

Condition

VersionNumber

Returns the version number of an item

ToInteger

Transforms and type-casts an integer value string into an integer value.

Max

Returns the maximum value in a set of integer values.



2. Using SW client version 1.48.0.20656 (Release Date: 2017-11-16) or later

Path query:

AllVersions.MaxByDate(CreationDate)

Item

Description

AllVersions

Returns all versions of an item.

MaxByDate

A new SW method that returns the object from the list with the latest date property.

CreationDate

Returns the creation date for applicable SystemWeaver objects.


Best Regards
Bashar

One limitation of the first option is using Branch in versioning, which will result in including characters in the version number, for instance, Version=2a1.

The image below shows an example.

image

Best Regards
Bashar


1 person likes this

What if your list is not only numbers? ToInterger will then crash the script. It may be a list of strings intended for numbers but may also contain text provided by the user. How to test the list for numbers values only (e.g. $List[0..9] .ToInteger

Hi Mikael, 


If you wish to eliminate anything that is not a number, then this should work: 


AllVersions[VersionNumber.ToString.Matches('^[0-9]*$')]


Best regards, 

SystemWeaver Support

Login to post a comment