Substring
  • 08 Dec 2022
  • 1 Minute to read
  • Dark
    Light

Substring

  • Dark
    Light

Article Summary

Step Details

Introduced in Version4.0.0
Last Modified in Version7.12.0
LocationData > Text

The Substring step extracts characters, between two positions, from a string and returns the substring.




Properties

Inputs

PropertyDescriptionData Type
InputThe string to break into a substring.String
LengthThe desired length of the substring.

If this number exceeds the input length, the step will not break the input into a substring regardless of the start index.

If this number paired with the defined start index is longer than the length of the input, the step will cause an error.
Int32
Start IndexThe index in which to start the substring. Starting index is 0.

This number can not be larger than the length of the substring, or the step will cause an error.
Int32

Outputs

PropertyDescriptionData Type
Substring1_OutputThe part of the string that was extracted.String

Example Inputs and Outputs

InputLengthStart IndexOutput
Hello World50Hello
Hello World56World
Hello World122Hello World
Hello World66EXCEPTION MESSAGE
Hello World212EXCEPTION MESSAGE
Null Value66No Output Present
Empty String66Empty String


Common Errors

Index and length must refer to a location within the string

If the Length paired with the defined Start Index is longer than the length of the Input, the step will cause an error.

To correct this, change the length or the starting index not to exceed the input's length.

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Substring 1[Substring] in flow [Display Steps]: Exception invoking method Substring on class StringSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method Substring on class StringSteps
 ---> System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. (Parameter 'length') 
   at System.String.Substring(Int32 startIndex, Int32 length)    
   --- End of inner exception stack trace --- 
   at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.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 ---


StartIndex cannot be larger than length of string

If the Start Index number is larger than the Length of the substring, the step will cause an error.

To correct this, change the Start Index not to exceed the Length.

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Substring 1[Substring] in flow [Display Steps]: Exception invoking method Substring on class StringSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method Substring on class StringSteps
 ---> System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex'
 at System.String.Substring(Int32 startIndex, Int32 length)
   --- End of inner exception stack trace --- at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.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?