A single-character slice of a text variable in the formula field evaluates to "undefined"

File this under “molehills turning into mountains”:

I’m trying to use a flow function to set one page variable using a formula that is dependent on picking out a certain character from another page variable. However, the usual pageVars.xyz[#] syntax keeps evaluating to “undefined” according to the debugger. I can’t figure out why, and it’s driving me absolutely insane – it seems like the tiniest, least complex problem in the world but it’s had me stuck for hours.

To simply illustrate the issue, I created a page variable called “test” of type = text and initial value = “abc”.

Evaluates to “a” when the flow function is triggered:


Evaluates to “abc” when the flow function is triggered:

Evaluates to “undefined” when the flow function is triggered:


You’ll notice that the formula example results expect the string slice to evaluate to a character… and yet, when previewing my app and looking at the debugger, it just doesn’t.

Please help because I’m about to throw my laptop out the window. THANK YOU!


This is actually a bug since Composer doesn’t support “text”[0] type of notation, so the undefined response is the correct one in this case. I have filed a bug report about the formula editor suggesting a response other than undefined to prevent any further confusion, thanks for bringing this to our attention!

Perhaps a formula function like SUBSTRING() would help you to get specific letters from a string?

Thanks for filing it! Is there a reason AppGyver shouldn’t/won’t support “string”[0] notation for variables? The fact that my “abc”[0] example evaluated to “a” makes it seem like it should be very attainable, and it is a helpful functionality.

I ended up discovering & using STRIP_RIGHT() and STRIP_LEFT() because what I wanted was the first or second character in a two-character string.


Great that you found a workaround for your app!

I’d say the main reason for Composer not supporting this is that it is generally considered bad practice compared to using functions intended for it, such as the available formula functions or other javascript functions ( like charAt(i) ). In case the string variable is undefined, it might cause your app to crash completely when using bracket notation “abc”[0], while the functions don’t cause as much trouble. Also, the bracket notation is not supported in older browsers :slightly_smiling_face: