Save to state

Hi,

I have a strange problem that the variable does not want to be saved in the Save to State action when I use it in Automations. I call the Action from the Loop and first I want to save something from {{data.xy}}, but it does not happen!

Any idea?

TIA,

Stane

Hi @Karlek!

I just tested it with the code below (in the Save to State step):

const newUsername = {{data}}; // Get the string to append
const usernamesArray = {{state.usernames}}; // Get the current array of usernames

// Append the new username to the array
usernamesArray.push(newUsername);

// Return the updated array
return usernamesArray;

And I got both values appended to the initial value in the state variable after Loop step:



Could you please share more details about your automation?

In Loop I call Action and pass data with object.


I put tid item from object to State:

But State value is β€œβ€

What I’m missing?

TIA,

Stane

Thanks for your reply!

As State Variables are exist only in context of a single Automation run β€” you won’t see the current value in the Builder interface. But during the Automation run the value will be available for steps via {{state.m_tid}}.