How to convert array into single value against a single key

Certified Lead Developer

I've CDT which has data like {ID:1, Val: "A,B,C}. Now I want to store the values in another CDT and write to DB where I want to save them in manner like {ID:1, Val:"A", ID:1, Val:"B",ID:1, Val:"C"}. What can be done to achieve this.

Regards:
Nitesh

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    No!  I realize what you need to do!  Specifically because you want to write to database.

    If I understand your question correctly you have:

    {

    ID: 1,

    Val: "A, B, C"

    }

    and you want A, B, C to each get their own row with a 1 foreign key?  Just split the string. Use split() on "A,B,C" with the comma as your separator, and you should wind up with:

    {

    ID: 1

    Val: {"A";"B";"C"}

    }

    And Appian should automatically save that in DB how you would want it to be saved.

Reply
  • 0
    Certified Lead Developer

    No!  I realize what you need to do!  Specifically because you want to write to database.

    If I understand your question correctly you have:

    {

    ID: 1,

    Val: "A, B, C"

    }

    and you want A, B, C to each get their own row with a 1 foreign key?  Just split the string. Use split() on "A,B,C" with the comma as your separator, and you should wind up with:

    {

    ID: 1

    Val: {"A";"B";"C"}

    }

    And Appian should automatically save that in DB how you would want it to be saved.

Children
No Data