Have Questions?  Need Expert Answers?  JOIN LUNCH N' LEARNS!

Add Item/Items to List

Prev Next
Step Details
Introduced in Version4.0.0
Last Modified in Version8.8.71075
LocationData > Text

The Add Item to List step adds an item to a list if it is the same datatype with an index starting from zero. The step requires both the input item and the list item to be the same datatype; otherwise, an error will be thrown.


Properties

Data

PropertyDescriptionData Type
AddToListPositionThe position where the new item will be added. The new item can be added at the start, end, or at a specified index.---
ListTypeThe datatype for the added list.---

Inputs

PropertyDescriptionData Type
IndexAvailable if AddAtIndex is selected for the AddToListPosition PropertyInt32
New ItemThe item to be inserted into the list. The item must match the datatype of the list, otherwise an error will be thrown.Varies, dependent on the ListType Property
Original ListThe list that the new item will be added to. Varies, dependent on the ListType Property

Outputs

PropertyDescriptionData Type
New ListTA list which contains the newly added itemVaries, dependent on the ListType Property.

Example Inputs and Outputs

New ItemAddToList PositionOriginal ListOutput
Hello WorldAddToBegining{"FirstItem", "SecondItem", "ThirdItem"}{"Hello, World", "FirstItem", "SecondItem", "ThirdItem"}
Hello WorldAddToEnd{"FirstItem", "SecondItem", "ThirdItem"}{"FirstItem", "SecondItem", "ThirdItem" Hello, World"}
Newly Inserted ItemAddAtIndex, 2{"FirstItem", "SecondItem", "ThirdItem", "FourthItem"}{"FirstItem", "SecondItem", "Newly Inserted Item", "ThirdItem", "FourthItem"}



Add Item to List

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 Decisions Studio, select CREATE FLOW from the Global Action Bar and select Flow. Name the Flow and click CREATE. 
  2. Click SETUP INPUT DATA and select DEFINE.
     
  3. On the Input Data window, enter "ListData" under NAME and select String [Text] under TYPE. Select the checkbox for IS LIST.
     
  4. Under INPUT, click the pencil icon. Then, select Constant as the mapping type and enter "Test 1", "Test 2", and "Test 3" separating each value by line. Click DONE. Click Save and close the window.
  5. From the Toolbox panel, navigate to DATA > LIST and add an Add Item to List step to the Start step.
     
  6. From the DATA category on the Properties panel, select AddToEnd for the AddToListPosition option and String [Text] for 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.
  7. Under the INPUTS category, click Unknown next to the Original List field and select Select From Flow. Select List Data and click DONE. Enter "Test 4" in the New Item field.  

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

Common Errors

Source array was not long enough. Check the source index, length and the array's lower bounds.

This error appears if the array's length is less than the value used for the Index. The step will throw the following error. Ensure that the value for the index is less than or equal to the size of the array.

Exception Message:

Exception Message: Error running step Add Item to List Step 1[AddItemToListStep] in flow [Example Flow]: Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray')
Input Values:
-- No Data --
Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Add Item to List Step 1[AddItemToListStep] in flow [Example Flow]: Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray') ---> System.ArgumentException: Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray')
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at DecisionsFramework.Design.Flow.CoreSteps.AddItemToListStep.Run(StepStartData data)
   at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData)
   at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData) 
   --- End of inner exception stack trace ---

Example:

 New Item
AddToList Position
Original ListOutput
Hello WorldAddAtIndex, 5{"FirstItem", "SecondItem", "ThirdItem"}
EXCEPTION MESSAGE