Hi,
Thank you for your query.
It is impossible to pass Input Parameters to a workflow and grab its output in JavaScript. It is not designed in this way.
Workflows are triggered on an event and take input from Workflow itself (not from calling code).
As you already mentioned, for this purpose we use Actions.
Anyhow, if it is necessary to use a workflow, you can do the following:
- Create fields in the entity for storing input parameter values.
- In the workflow custom code activity, pass these fields data as parameters.
- From your JS function, first, update these fields (with the data you need to pass as parameters), save the data, and then call workflow.
To capture the output, you again need to store it in a field in the entity, so later you can read the value of this field in JS. Also, if the workflow is async (background), it is impossible to catch updated data in the JS (as we are not sure when the workflow will run).
In my opinion, I do not see why this needs to be done using a workflow, you can re-use the same custom code activity inside Action also, so create an action and use it in the JS.