I am looking for the equivalent to select max(property) in IOM.
The below SQL query returns exactly what I want, but I understand that this should be used as a last resort and want to make sure I'm not missing something.
select MAX(item_number)
FROM [InnovatorServer27_Dev_HL].[innovator].[PART]
where part.item_number like '1010P%'
result: 1010P000002
This is the function within my method that I'm working with.
string GetNextBaseNumber(Innovator inn, string PartNumberPrefix)
{
int BaseNumber = 1;
// This query is currently returning a collection when I want it to return the max value
Item Part = inn.newItem("Part", "get");
Part.setProperty("item_number", PartNumberPrefix + "%");
Part.setPropertyAttribute("item_number", "condition", "like");
Part = Part.apply();
if (!Part.isEmpty())
{
BaseNumber = Int32.Parse(Part.getProperty("item_number").Substring(5,6))+1;
}
return PartNumberPrefix + BaseNumber.ToString().PadLeft(6, '0');
}