Is there any way to sort text array in Appian, without using a plugin?

Is there any way to sort text array in Appian, without using a plugin?

OriginalPostID-170628

OriginalPostID-170628

  Discussion posts and replies are publicly visible

Parents
  • @komalk To the best of my knowledge, this can be done OOTB without any plugin or CDT.

    We can accomplish the requirement by taking advantage of the Appian's Complex System Data Type namely 'LabelValue' (https://forum.appian.com/suite/help/7.10/Appian_Data_Types.html#LabelValue) which is present OOTB and thereby we can avoid depending on a CDT as well. Here is the rule for doing so:

    Name:
    sortTextArray

    Input(s):
    1. textArray (Text Multiple)
    2. isAscending (Boolean)

    Output:
    sorted text array (textArray is not empty) or null (if textArray is null or empty)

    Definition:
    if(
    \trule!APN_isEmpty(array:ri!textArray),
    \tnull,
    \twith(
    \ tlocal!arrayOfLabel:fn!apply(type!LabelValue(label:_),ri!textArray),
    \ tlocal!sortedDataSubset:fn!todatasubset(
    \ tarrayToPage:local!arrayOfLabel,
    \ tpagingConfiguration:a!pagingInfo(startIndex:1,batchSize:-1,sort:a!sortInfo(field:"label",ascending:ri!isAscending))
    \ t),
    \ tlocal!sortedTextArray:fn!property(local!sortedDataSubset.data,"label",null),
    \ tlocal!sortedTextArray
    \t)
    )


    Ex1: rule!sortTextArray(textArray:{"Pega","Appian","Lombari","Bonita"},isAscending:fn!true()) --> Appian; Bonita; Lombari; Pega
    Ex2: rule!sortTextArray(textArray:{"Pega","Appian","Lombari","Bonita"},isAscending:fn!false()) --> Pega; Lombari; Bonita; Appian

    Attached the rule for your convenience.
Reply
  • @komalk To the best of my knowledge, this can be done OOTB without any plugin or CDT.

    We can accomplish the requirement by taking advantage of the Appian's Complex System Data Type namely 'LabelValue' (https://forum.appian.com/suite/help/7.10/Appian_Data_Types.html#LabelValue) which is present OOTB and thereby we can avoid depending on a CDT as well. Here is the rule for doing so:

    Name:
    sortTextArray

    Input(s):
    1. textArray (Text Multiple)
    2. isAscending (Boolean)

    Output:
    sorted text array (textArray is not empty) or null (if textArray is null or empty)

    Definition:
    if(
    \trule!APN_isEmpty(array:ri!textArray),
    \tnull,
    \twith(
    \ tlocal!arrayOfLabel:fn!apply(type!LabelValue(label:_),ri!textArray),
    \ tlocal!sortedDataSubset:fn!todatasubset(
    \ tarrayToPage:local!arrayOfLabel,
    \ tpagingConfiguration:a!pagingInfo(startIndex:1,batchSize:-1,sort:a!sortInfo(field:"label",ascending:ri!isAscending))
    \ t),
    \ tlocal!sortedTextArray:fn!property(local!sortedDataSubset.data,"label",null),
    \ tlocal!sortedTextArray
    \t)
    )


    Ex1: rule!sortTextArray(textArray:{"Pega","Appian","Lombari","Bonita"},isAscending:fn!true()) --> Appian; Bonita; Lombari; Pega
    Ex2: rule!sortTextArray(textArray:{"Pega","Appian","Lombari","Bonita"},isAscending:fn!false()) --> Pega; Lombari; Bonita; Appian

    Attached the rule for your convenience.
Children
No Data