How to send a form PDF via the JSON tool
Hi,
I am a trying to use the JSON tool to send the PDF of a form to a content server. Similar idea to the Export Form Email tool but instead of sending via email, the PDF will be sent using the content server API. So far I have been able to authenticate with the content server and pass basic data using the JSON tool. However I do not know how to generate a PDF and send it via the tool.
Anybody would know how to do that?
I tried to use a process variable to store the byte stream but unfortunately I got this error. Looks like process variables take only strings ...
945
ERROR 09 Oct 2020 14:36:51 Shark - Activity[Process Id=19_json_tool_dx_kb_process1, Id=37_19_json_tool_dx_kb_process1_tool3, ba=null, ActDefId=tool3] - failed to set the activity result
946
WARN 09 Oct 2020 14:36:51 org.joget.workflow.model.service.WorkflowManagerImpl - Invalid data type for variable formpdf, required type=java.lang.String, provided type=class [B, oldval=, value=[B@603d39f4
This is the bean shell code that I am trying to use
import org.joget.apps.app.model.AppDefinition;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.service.FormPdfUtil;
import org.joget.workflow.model.service.*;
AppDefinition appDef = AppUtil.getCurrentAppDefinition();
String formId = "form1";
String id = "0001";
//generate the pdf file in bytes
byte[] pdf = FormPdfUtil.createPdf(formId, id, appDef, null, null, null, null, null, null, null, null);
WorkflowManager wm = (WorkflowManager) pluginManager.getBean("workflowManager");
wm.activityVariable("#assignment.activityId#","formpdf", pdf);