Function Call With A Parameter - What Am I Doing Wrong?

I’m trying to create a javascript function call from a flow to do a “Copy to Clipboard” function.

When call the flow, the javascript isn’t called. There is no console error message. It also seems to abort the running of the flow, and statements placed afterwards in the runJS part of the flow don’t execute.

Can anyone help me see where I am going wrong?

I have a flow like this:

<script is="dmx-flow" id="flow_c2c" type="text/dmx-flow">{
  meta: {
    $param: [
      {type: "text", name: "phrase"}
    ]
  },
  exec: {
    steps: [
      {
        run: {action: "{{notification.success($param.phrase)}}"} // this works, but only if before the runJS
      },
      {
        runJS: {
          function: "js_copy_to_clipboard",
          args: ["{{$param.phrase}}"],
          name: "js_copy_to_clipboard",
          output: true
        }
      }
    ]
  }
}</script>

Which I call like this:

dmx-on:click="flow_c2c.run({phrase: 'banana'})"

And the JS is like this:

<script>
	function js_copy_to_clipboard(copyText) {
      /* Select the text field */
      copyText.select();
      copyText.setSelectionRange(0, 99999); /*For mobile devices*/

      /* Copy the text inside the text field */
      document.execCommand("copy");

      /* Alert the copied text */
      alert("Copied the text: " + copyText.value);
      console.log("Copied the text: " + copyText.value);
    }
</script>
Community Page
Last updated: