Additionally, there is a JS external worker. In this worker, I have a const age = task.variables.get(“age”); statement to retrieve the value of the variable “age”. This works as expected.
The question is, how could I retrieve the base64 value of the “document1” variable and its mimetype???
When I try to have const document1 = task.variables.get(“document1”); and then print in the console the document1 variable, I see something like this:
If you want to use an external Task Worker with non-primitive data types, I recommend serializing and deserializing the objects explicitly. This way, you have full control over their format.
The documentation has an article about data formats, which may help you:
However, the JS-Client provides an interface for handling files:
Calling the load function loads the file from the remote path. Once the call completed, content should contain the base64 value of the file.
I see the following in the console, but the file content is never printed out.
External JS worker started!!!
✓ subscribed to topic APIcall
TESTABC Smith Johnson smithtest@gmail.com
/execution/c51e12f8-754c-11ed-9db5-d850e649bc61/localVariables/document1/data
Are the following statements correct? Apparently, I miss something, but I don’t know what
const { Client, logger, File } = require("camunda-external-task-client-js");
const document1 = task.variables.get("document1"); // the name of the process variable is "document1"
const file = await new File({ remotePath: document1.remotePath }).load();
Thank you once again for your time and help,
Smith.
Unfortunately, I’m not very familiar with the Javascript client.
Is document1 a File, as described in your first post?
If so, what happens, if you call document1.load()?