Updating a CDT array with a single value in a process model

Hi all,

Before writing a CDT array to the database in my process model, I want to update all elements of the array with a different value. How can I do this?

For example, let's say I have a process variable named pv!myCDT (which is a CDT array) with this value:

{
    {
        name: "Ben",
        age: 60,
        retired: false
    },
    {
        name: "Sam",
        age: 65
        retired: false
    }
}

and I want to update all 'retired' fields to true. How can I do this in a process model? Should I use a script task for this?

I tried using a script task and added a custom output but this only changed the first element. It looked like this:
Expression = 'true',
Operator = 'is stored as'
Target = pv!myCDT.name

Thanks for the help! Slight smile

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Fabiant,

    You can try below methods,

    1- As you mentioned, you can map/update the values using a script task in the variable.

    2- you can use saveInto of your form buttons too. While submitting, you can update this field alone, so that the CDT variable will have this field updated and you can use write to DSE to update into the database.

    3- You can use updatecdt() function (it's not an OOTB function). 
    ex snippet - 


    updatecdt(
    ri!myCDT,
    {
    retired: repeat(
    length(
    ri!myCDT
    ),
    true()
    )
    }
    )

Reply
  • 0
    Certified Lead Developer

    Hi Fabiant,

    You can try below methods,

    1- As you mentioned, you can map/update the values using a script task in the variable.

    2- you can use saveInto of your form buttons too. While submitting, you can update this field alone, so that the CDT variable will have this field updated and you can use write to DSE to update into the database.

    3- You can use updatecdt() function (it's not an OOTB function). 
    ex snippet - 


    updatecdt(
    ri!myCDT,
    {
    retired: repeat(
    length(
    ri!myCDT
    ),
    true()
    )
    }
    )

Children
No Data