Skip to main content
January 16, 2025
Question

Does any one aware of sort ??

  • January 16, 2025
  • 3 replies
  • 0 views

Hi,

BELOW Is SORT where we used 

a!save(local!a,

index(sort(somevalue)),1,Null)

Now after upgrading im getting error in interface invalid function {"SORT"}

WHAT is the replacement of SORT NOW

3 replies

shivar8114
January 16, 2025

 [mention:c23375782d6c45128ac1aec92ddd9df2:e9ed411860ed4f2ba0265705b8793d05] 

Actually we can use a!sortinfo function only be referenced by the PagingInfo and DataSubset types so if you want the use the sorted data, query the data and sort by your specified value and save in local variable (eg: local!sortData) then use your local variable as below
 
a!save(local!a,
index(local!sortData,1,null))

nilanshum856600
January 16, 2025

Sort() is an undocumented function and should not be used. Instead, you can convert your data into a data subset using todatasubset() function and then use the sort parameter in the paging info using a!sortinfo.

For your reference: https://docs.appian.com/suite/help/24.4/fnc_scripting_todatasubset.html#examples

amaans4178
January 16, 2025

The sort function is not documented by Appian and is not recommended for use in your code. Instead, adding to what Nilanshu said you can use todatasubset() function to sort your data by providing sortInfo, 
eg : 

a!localVariables(
  local!array: { 1, 11, 9, 2, 7, 0 },
  local!fieldArray: a!forEach(
    items: local!array,
    expression: a!map(id: fv!item)
  ),
  local!datasubset: fn!todatasubset(
    arrayToPage: local!fieldArray,
    pagingConfiguration: a!pagingInfo(
      startIndex: 1,
      batchSize: - 1,
      sort: a!sortInfo(field: "id", ascending: true)
    )
  ),
  local!datasubset.data.id
)


Additionally, if your 'somevalue' only contains integers/dates, the min() function would be a more efficient alternative in this scenario.