Share feedback, ideas and get community help

Updated 5 months ago

Variables to Zapier from javascript

At a glance

The community member is using a Set variable block with custom JavaScript to retrieve a cookie value and store it in a variable. The variable can be retrieved and displayed in the chat, but when the community member tries to return the variable using a Zapier block, the variable is not included in the return. The community member notes that variables set through an Input Text block with "Save the answer in a variable" do show up in Zapier, but the variables set through the Set variable block with JavaScript do not. The community member is asking for help to understand what they are doing wrong.

In the comments, another community member is struggling to understand the Zapier part and is asking for more information, such as steps to reproduce, what's happening, what the community member was expecting, and a screen recording if possible.

There is no explicitly marked answer in the post or comments.

I am using a Set variable block with value: Custom. I have this javascript in it (Execute on client? = true):

function getCookie(name) {
const value = ; ${document.cookie};
const parts = value.split(; ${name}=);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const myCookieValue = getCookie("hubspotutk");
return myCookieValue

The variable gets set, I can retrieve the value and print it as a text bubble in the chat.

However, for some reason when I try to return the variable using a Zapier block, the variable isn't included in the return. The variable just isn't there.

Any variables I set through an Input Text block using "Save the answer in a variable" DO show up in Zapier. But these that I'm setting through the Set variable block with JS are not.

Any idea what I'm doing wrong?
B
1 comment
I'm struggling to understand the Zapier part

  1. Steps to reproduce
  2. What's happening
  3. What were you expecting
It's even better if you can provide a screen recording.
Add a reply
Sign up and join the conversation on Discord