Hi, not sure if you have a question or if you already solved the issue. Anyway, based on my previous example, this is how you can access the payload and assign values to other variables in the script
Lets assume, you send a javascript object {"name":"jmacle"} as payload to the ui_template node
In the template node, the script captures the payload, sends it further to the debug node then extracts the "name", assigns it to you new variable bleh, and sends the value of bleh to the debug node
As soon as you have assigned the value to bleh, you can do whatever is required, basically just extend the function otherStuff
Hope this helped you
<!DOCTYPE html>
<html>
<script type="text/javascript">
var theScope = scope;
var bleh = null;
// Watch the payload and update
(function(scope) {
scope.$watch('msg.payload', function(data) {
update(data);
});
})(scope);
function update(dta) {
theScope.send({payload:dta});
bleh = dta.name;
otherStuff();
}
function otherStuff() {
theScope.send({payload:bleh});
}
</script>
</html>
[{"id":"20cb4ed7.366822","type":"ui_template","z":"d01d2553.fd9838","group":"16fdc5e1.9ee0fa","name":"","order":0,"width":0,"height":0,"format":"<!DOCTYPE html>\n<html>\n<script type=\"text/javascript\">\nvar theScope = scope;\nvar bleh = null;\n\n// Watch the payload and update\n(function(scope) {\n scope.$watch('msg.payload', function(data) {\n update(data);\n });\n})(scope);\n\nfunction update(dta) {\n theScope.send({payload:dta});\n bleh = dta.name;\n otherStuff();\n}\n\nfunction otherStuff() {\n theScope.send({payload:bleh});\n}\n\n</script>\n</html>","storeOutMessages":false,"fwdInMessages":false,"templateScope":"local","x":940,"y":380,"wires":[["e5bfeff6.d88e2"]]},{"id":"4e748181.57245","type":"inject","z":"d01d2553.fd9838","name":"","topic":"","payload":"{\"name\":\"jmacle\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":880,"y":290,"wires":[["20cb4ed7.366822"]]},{"id":"e5bfeff6.d88e2","type":"debug","z":"d01d2553.fd9838","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1040,"y":460,"wires":[]},{"id":"16fdc5e1.9ee0fa","type":"ui_group","z":"","name":"Buttons","tab":"8f57f520.e87078","order":1,"disp":false,"width":"6","collapse":false},{"id":"8f57f520.e87078","type":"ui_tab","z":"","name":"Some buttons","icon":"dashboard","order":1}]