Skip to content

A JavaScript step in a BPA workflow throws 'Selection.substring is not a function' when trying to extract a substring from a workflow execution variable, even though .indexOf() on the same variable works fine just before it.

Answer

Check whether the variable is actually a JavaScript array (a multi-record collection) rather than a plain string — execution.getVariable() can return an array when the underlying workflow variable represents multiple records, and array objects don't have string methods like .substring() directly on them. If that's the case, index into the specific element you need first (e.g. SelectionTab[0].substring(...)) rather than calling the string method on the array itself. Also remember JavaScript method names are case-sensitive — substring (lowercase s) works, Substring does not.

← Browse Workflows and automation questions