How to set a page variable value to the output of a custom javascript block?

I have a component, which on tap triggers a custom javascript block. This block returns a string as its output. Now I have a page variable “total” which is of type string. How do I set its value to the output of the custom javascript block?

I tried connecting a set page variable block after the custom javascript block and tried to set the value of the page variable “total” of type ‘output value of another node’ but the only option in the dropdown available is ‘Component tap/Event’. This sets the value of the page variable to ‘undefined’. Please help.

Looks like there’s a bug – direct string result is not usable as an output property; you need to return an object with a string type property:

This of course would require calculateResult to be defined as a valid function defined before line 1 there. For those not familiar with ES6, { result } is equivalent to { result: result }

If you set up your output to be an object like this, you can use the Output value of another node binding type. to follow the bug. Sorry for the hassle!


Thanks a lot. This worked smoothly.

1 Like