Skip to main content
February 8, 2023
Solved

Split Value

  • February 8, 2023
  • 5 replies
  • 0 views

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.

Best answer by jonesprakashs0001

Hi,

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

5 replies

jonesprakashs0001
February 8, 2023

Hi,

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

February 8, 2023

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

February 8, 2023

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
February 8, 2023

And you can even omit all the local variables.

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