How do I modify records with a ForEach loop?

I have a list of a complex data type and I want to use a ForEach loop to go through the list and update just 1 field in each record. What's the best way to do this, would Update Entity work?

Comments

  • While the Update Entity step can be used to modify the 'Item' entity in a ForEach loop using the Item.ID as the reference, this step is considered deprecated and is no longer recommended.


    You can instead use a 'Save Entities' step by setting the 'Entity' input to 'Build Data'. For the fields you don't want to update, map these inputs to their corresponding fields on your ForEach Item's fields, then map in the new value to the field you want to update.


    In the example screenshot below the flow creates a new list, fetches all objects for my data type, then loops through them changing the 'Name' field to a new random name with the 'Save Entities' step.


    Please note the 'Save Entities' step overrides all fields, so if any are set to 'Ignore', they will be overwritten as 'Null' in the database, so be sure to map in values for all fields you want to retain.

    (The Item ID is required to save the entity and it can't be changed.)


    For more information on the Save Entities and Update Entity steps, please see the below documentation pages:

    https://documentation.decisions.com/step-library/docs/save-entities

    (Deprecated) https://documentation.decisions.com/step-library/docs/update-entity

Sign In or Register to comment.