Trigger workflow/change variable value from link in text

I have a text element in which I want to have a link.

As far as I know, there are two ways to do this:
First, use plain text, select the text and add a link to it.
Second, write the text in HTML, with a <a href="" onclick=""></a> element.

The first option is very limited; for instance it is not possible to trigger a workflow or change a variable value from the link editor.

How do I either trigger a workflow or change a variable value when my HTML element is clicked?
I’ve tried to use a custom JS function, without success (the console returns that the “myFunction” function is undefined):

function myFunction() {
alert('hello world!');
}

<a onclick='myFunction();'>Click me</a>

I’ve also tried to use wwLib.wwVariable.updateValue(), also without success:

return "<a onclick='"+wwLib.wwVariable.updateValue(varID, varValue)+"'>Change variable value</a>"

Hi, you’re not too far of the solution, here mine

You can create your workflow, get its UID and call it in your HTML by using our wwLib.executeWorkflow, you can even give some parameters to your workflow to be able to identify the source of the link if you want to reuse it for multiple links in the same text but need to know what has been clicked

Link A : <a onclick="wwLib.executeWorkflow('2a145a9b-9ae4-4425-9ca6-da03c73eb8a7', {myParam: 'Link A'})">Execute Workflow</a>
Link B : <a onclick="wwLib.executeWorkflow('2a145a9b-9ae4-4425-9ca6-da03c73eb8a7', {myParam: 'Link B'})">Execute Workflow</a>
1 Like