Manipulating Lists
  • 09 Jun 2022
  • 3 Minutes to read
  • Dark
    Light

Manipulating Lists

  • Dark
    Light

Article Summary

Overview 

Lists of any Data Structure can be manipulating using steps found under Data > Lists in the step Toolbox. The following document discusses how to use three List manipulation steps (Add Item(s) to List, Remove Item From List, and Get Item By Index) to edit Lists.


Creating Lists 

Lists can be created as input data to a Flow. This input data will be referenced for other steps. To create a List from the Flow Designer out of any Data Type: 

  1. From the Decisions Studio, select CREATE FLOW from the Global Action Bar, then create a new Flow
  2. From the Flow Designer select the SETUP INPUT DATA button from underneath the top Action bar.
  3. From the FlowInput Data window, select DEFINE. 
  4. From [FlowName] : Input Data, provide a NAME. Then under TYPE, select desired Data Type (for this example select String [Text]). Then, check the IS LIST Boolean

  5. Under INPUT, select the Edit (pencil) icon. Then, Constant map the desired List of String Input, separating each value by line. Then click DONE. 

  6. Save the Input Data, then close the window via X.



Add Item to List Step 

The Add to List Step is used to append a List by adding a new Item of the matching Data Type to that List. A new list with the added Item will be created.

InputsDescription
New ItemThe new item which will be appended to the List.
Original ListThe inputted list which will be manipulated.
  1. From the Flow Designer, from the Toolbox tab, navigate to Toolbox > DATA > LIST, and add an Add Item to List Step to the Start step. 
  2. Select the Add Item to List Step to navigate to its Properties tab. 
  3. Under the step's Data header in the Properties tab, select the desired AddToListPosition. Then select the corresponding ListType.
     
    The AddToListPosition Property allows users to dictate where the new value is placed in the List. Users have the option to either AddToBeginning or AddToEnd.
    AddListToPositionDescription
    AddToBeginningInserts the item at the beginning of the List.
    AddToEndInserts the item at the end of the List.
    ListType is used to select the compatible Data Type value of the List being added to. For this example, leave ListType set to String [Text].
  4. Under Properties > INPUTS, change the Original List input type to Select From Flow map in the Input Data. Then Constant map a New Item

  5. From the Flow Designer, select the Debug link from the top Action bar. 
  6. Click START DEBUGGING. Select the step and verify that the New Item was added to the Original List

Add Items to List Step 

Similar to the Add Item to List Step, the Add Items to List step is used to append multiple items to a List. Instead of needing a single item, this step requires a list of the specified datatype as an input.


Get Item By Index by Index 

The Get Item by Index step is used to obtain values from an existing List by providing an Item Index for context of its location within the List.

InputsDescription
Item IndexRepresents an Item's position in the List, starting from 0.
ListInputted list where the item will be pulled from
  1. From the Flow Designer, navigate to DATA > LIST and attach a Get Item by Index step to the Add Item to List Step.
  2. From the Properties tab of the Get Item by Index step, under INPUTS, Select From Flow map the Output from the Add Item to List Step (New List) to the List Input
  3. Under Item Index, Constant map the desired Int32 numerical value.

  4. From the Flow Designer, select the Debug link from the top Action bar. 
  5. Click START DEBUGGING. Select the step and verify that the selected Item is correct. 

Remove Item From List 

The Remove Item From List step is used to remove a designated Item (Item to Remove) from a defined List. Both Items and List may be dynamically mapped, or Constant mapped onto each Property respectively.

InputsDescription
Item To RemoveItem that will be removed from the List. 
ListThe inputted list to be manipulated by the step.
  1. From the Flow Designer, navigate to Toolbox > DATA > LIST, and attach a Remove Item from List step to the Get Item by Index step as well as the End step. 
  2. From the Properties tab of the Remove Item from List step, Select From Flow map New List to the List Input.
  3. Map List Item to Properties > INPUTS > Item to Remove
  4. Save the Flow, then if desired close the Flow Designer via X.
  5. From the Flow Designer, select the Debug link from the top Action bar. 
  6. Click START DEBUGGING. Select the step and verify that the selected Item is removed. 

Was this article helpful?