how to save array of values in CDT in process model

Certified Associate Developer

For example, I have process variables arrays

        name : {"a","b","c","d"},

        age : {1,2,3,4},

        email : {"@e","@r","@t","@w"}

and I have a CDT which has {name,age,email} 
How can I save those array values in my CDT  in process model? bcz when I try to use script task to save the array values in CDT and write in the db using cdt  then only first row is getting written in db.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    You should first cast this data to your CDT.

    Check this out:

    a!localVariables(
      local!data:{
        name : {"a","b","c","d"},
    
        age : {1,2,3,4},
    
        email : {"@e","@r","@t","@w"}
      },
      a!forEach(
        items: local!data.name,
        expression: type!<<cdt_name>>(
          name: fv!item,
          age: index(local!data.age,fv!index,{}),
          email:index(local!data.email,fv!index,{})
        )
      )
    )
     

    This is not the most appropriate way, But it will work.

Reply
  • 0
    Certified Senior Developer

    You should first cast this data to your CDT.

    Check this out:

    a!localVariables(
      local!data:{
        name : {"a","b","c","d"},
    
        age : {1,2,3,4},
    
        email : {"@e","@r","@t","@w"}
      },
      a!forEach(
        items: local!data.name,
        expression: type!<<cdt_name>>(
          name: fv!item,
          age: index(local!data.age,fv!index,{}),
          email:index(local!data.email,fv!index,{})
        )
      )
    )
     

    This is not the most appropriate way, But it will work.

Children
No Data