How to update a column value of multiple records in a table?

Scenario:

Update Column "X" in table "A" for an array of record identifiers of records in table "A". Value will be same value for all the list of record identifiers in their column "X".

Is this possible to achieve? If yes, how to do it, please share recipe or sample code.

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to anushas0002

    I just double-checked, and can confirm that updateCDT() requires the update property arrays to be the same length as the original CDT array.

    My suggestion is you do your querying / appending / updating in a step-by-step approach, using local variables for each step, to allow you to get each step working one at a time, and test each step.

     

    /* original code: */
    /* updatecdt(rule!GetTechnologyByIdMultiple(ri!ids),{Id: ri!ids, SourceIds: {2,2}}) */
    
    
    /* my suggestion: */
    with(
    
      /* initial query */
      local!initialQuery: rule!GetTechnologyByIdMultiple(ri!ids),
      
      /* now add the new entry.  you may or may not need to typecast it to your CDT type, I'm not sure. */
      local!appendedVersion: append(
        local!initialQuery,
        type!TechnologyCDT(
          Id: 2,
          SourceIds: 2
        )
      ),
      
      /* with UpdateCDT(), you only update the values that need updating - the rest stay untouched */
      local!updatedCdt: updateCdt(
        local!appendedVersion,
        {
          SourceIds: a!forEach(local!appendedVersion, 2) /* outputs "2" for every entry.  same as "repeat()" function but probably safer. */
        }
      ),
      
      
      /* finally, display the resulting value: */
      local!updatedCdt
    )

Children
No Data