Anyone know a way to update a CDT column dynamically using a custom rule or func

Anyone know a way to update a CDT column dynamically using a custom rule or function? I realize I can create a script task to loop through the CDT and set the column value. I just wanted a more dynamic way to doing it.

CDTa - can be multiple values.
CDT columns - column1, column2, column3

I want to loop through the CDT and set column2 to a specific numeric value

I reviewed the apply function and the custom plugins - IFM Manager, Set CDT Properties and CDT Manipulation - just wondering the most efficient option.

OriginalPostID-150052

OriginalPostID-150052

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    you can create a rule that takes in your CDT and the value you want to set and has a definition similar to =type!yourCDT(column1: ri!cdt.column1, column2: ri!valueToSet, column3: ri!cdt.column3). Then just apply over this rule with your list of cdts and values you want to set.
  • Hi dsmithgxp,

    Have a look at below, might help you:
    1) Let's say you want to update pv1_CDT.column2.
    2) Initially fill pv1_CDT by querying DB.
    3) Prepare an array type, with the values you want to update at column2.
    4) In script task output's use operator "is stored at index" to store above array at indices calculated by below expression:
    enumerate(length(pv!pv1_CDT))+1
    Look for error: The count of indices and the count of "values to update array" should be equal length.
  • @dsmithgxp Agree that there are various options to do so, but I would like to add one point as per my knowledge - Out of the options mentioned by you, IFM Manager is an option which you need to consider in case of making changes to a running instance. And rest of them, such as Set CDT Properties plugin, CDT Manipulation plugin, apply function in combination with type constructor (as said by joshl) are the options which are available at design time.
  • You can as well use below approach

    Expression
    ==========
    repeat(
    length(pv!YourCDT),
    true()
    )


    Target
    ===========
    pv!YourCDT.coloumnB
  • I am trying to replace a grid column with another column that has updated values like this -

    1.  a!save (local!temp, UpdateArray (ri!grid.Col1, {1, 3, 5}, "A")  updates the elements 1, 3, 5 with "A"  and returns just the Col1 array in local!temp with updated values.

    2.  How do I replace grid.Col1 with local!temp?

    a!save(ri!grid.Col1, local!temp) doesn't work as expected.  It replaces every element of ri!grid.Col1 with the entire array in local!temp!!!

    Thoughts?