Couldn’t find anywhere how to write the parameters in wwLib.executeWorkflow()
. Is it something like: wwLib.executeWorkflow('d43e2cda-2e70-4340-bf20-591717b09b9d',{'param1':'value', 'param2':'value'}
?
yes
Thank you @dorilama
For some reason my code isn’t working:
"Go to the <u onclick='wwLib.executeWorkflow(`d43e2cda-2e70-4340-bf20-591717b09b9d`,{`department_slug`:`hr`,`loader_message`:`Human ressources`})'>Human ressources</u> department"
Logs say that department_slug
parameter is missing.
Also, this code seems to make my editor crash
EDIT: now the editor doesn’t crash and there’s no log; the workflow just won’t get triggered. Code remains the same.
when you create the object you can’t use template literals for object name unless you treat them as dynamic keys.
this is what works: {a:1, 'b':1, "c":1, [`d`]:1 }
So this should work?
onclick='wwLib.executeWorkflow(d43e2cda-2e60-4340-bf20-591616b09b9d,{department_slug:hr,loader_message:test})'
I can’t use "
or '
since they’re used in my formula.
It doesn’t trigger the workflow on my side.
You need to “wrap” ‘it’ but not in `back ticks`
you need to use valid js: strings need to be wrapped in quotes, the id of the workflow and the values of the object properties (if strings) must be wrapped in quotes (single or double) or backticks.
the keys of the property must be valid js variable names, or be wrapped in quotes (single or double). if you want to use backticks you need to treat the key as a dynamic key like my previous example.
I’ve tried multiple combinations, such as
onclick='wwLib.executeWorkflow([`d43e2cda-2e60-4340-bf20-591616b09b9d`],{[`department_slug`]:[`hr`],[`loader_message`]:[`test`]})'
With this code, the workflow does get triggered, but the value of department_slug
doesn’t get through. No other combinations has worked.
If I used "
it would escape the formula (which starts with "
).
If I used '
it would escape the onclick
attribute.
you are trying random stuff without understanding what you are doing. when you leave the nocode way it is good to have a grasp of the basics of the coding language you use or you will end up wasting time like this.
try this: wwLib.executeWorkflow(`workflow-id-as-template-literal-string`, {[`your parameter key with arbitrary characters`]: `your value, assuming it is a string and not an array of strings`}
It works! Thank you @dorilama
great