Hi, I am trying to sort a text array and tried using the following recipe.

Hi,
I am trying to sort a text array and tried using the following recipe. forum.appian.com/.../Function_Recipes.html
Since this is just an array, not a record type, I am not sure what to put in as the field name to sort on in the data input tab. When I try to put in "field" as the value, I get an error evaluating expression. Any ideas? Thanks.
An error occurred while evaluating expression: departmentNameList:todatasubset(#"_a-0000d27e-8161-8000-8fc8-0a000064044c_72737",ac!pagingInfoNodeInput2).data (Expression evaluation error at function 'todatasubset': Error evaluating function 'todatasubset' : java.lang.IllegalArgumentException: The given data type is not a record type...

OriginalPostID-124071

OriginalPostID-124071

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hey, if you haven't figured it out, try something like this :

    load(
    local!textArray: {
    "b",
    "a"
    },
    local!tempCDT: apply(
    rule!toCDT,
    local!textArray
    ),
    local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: -1,
    sort: a!sortInfo(
    field: "field",
    ascending: true
    )
    ),
    todatasubset(
    local!tempCDT,
    local!pagingInfo
    ).data.field
    )

    rule!toCDT has one rule input called "text" (Type: Text), and is defined as:
    {field: ri!text}

    replace local:textArray from the first rule with the text array that you want to sort.

    Basically what the code does is converts your text array to a temporary "CDT" which just has one field (called field), that way when you make your pagingInfo you can give it a field to sort on. In the example above, the result is {"a","b"}
Reply
  • 0
    Certified Lead Developer
    Hey, if you haven't figured it out, try something like this :

    load(
    local!textArray: {
    "b",
    "a"
    },
    local!tempCDT: apply(
    rule!toCDT,
    local!textArray
    ),
    local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: -1,
    sort: a!sortInfo(
    field: "field",
    ascending: true
    )
    ),
    todatasubset(
    local!tempCDT,
    local!pagingInfo
    ).data.field
    )

    rule!toCDT has one rule input called "text" (Type: Text), and is defined as:
    {field: ri!text}

    replace local:textArray from the first rule with the text array that you want to sort.

    Basically what the code does is converts your text array to a temporary "CDT" which just has one field (called field), that way when you make your pagingInfo you can give it a field to sort on. In the example above, the result is {"a","b"}
Children
No Data