Skip to main content
Known Participant
Feb 8, 2023 2:32 AM UTC
Solved

Split Value

Hi Appian People!

I have this code that split the value inside the CDT.

So for example I have a CTD:

'type!{urn:com:appian:types}T_Sample'(
  name: "Person",

  place: "City1,City2,City3"

  
)

When splitting the value, the output should be like this in an array form:

Expected: ["Person"; "City1,City2, City3"]

But the actual result I got is:  ["Person"; "City1"; "City2; "City3"]

the place where split in different index where it shouldn't be.

This is my current code

local!splittedCDT:split(
    stripwith(
      tostring(
        ri!cdtVal
      ),
      "[] "
    ),
    ","
)
    
 local!updatedVal: a!forEach(
    items: local!splittedCDT,
    expression: replace(fv!item, 0, find("=", fv!item, 0), "")
  ),

Is anyone could help me with this? Thank You ahead.

jonesprakashs0001
Participating Frequently
Feb 8, 2023 6:53 AM UTC

Hi,

Hope this helps. (a!keys function will work for CDTs as well)

5 replies

jonesprakashs0001
Participating Frequently
Feb 8, 2023 6:53 AM UTC

Hi,

Hope this helps. (a!keys function will work for CDTs as well)

Known Participant
Feb 8, 2023 7:06 AM UTC

it wont work if the type is CDT, im always getting a result of null values even if my cdt has value. :'(

Participating Frequently
Feb 8, 2023 7:55 AM UTC

This can be achived in a much simpler way as follows:

a!localVariables(
local!keys: a!keys(ri!cdtVal),

local!updatedVal: a!forEach(
items: local!keys,
expression: index(ri!cdtVal, fv!item)
),
local!updatedVal
)
stefanhelzle0001
Brainy
Feb 8, 2023 7:57 AM UTC

And you can even omit all the local variables.

a!forEach(
 items: a!keys(ri!cdtVal),
 expression: index(ri!cdtVal, fv!item)
)