Add Item/Items to List
  • 27 Mar 2023
  • 1 Minute to read
  • Dark
    Light

Add Item/Items to List

  • Dark
    Light

Article summary

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 WorldAddAtIndex, 5{"FirstItem", "SecondItem", "ThirdItem"}
EXCEPTION MESSAGE
Hello WorldAddToEnd{"FirstItem", "SecondItem", "ThirdItem"}{"FirstItem", "SecondItem", "ThirdItem" Hello, World"}


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 ---

Was this article helpful?