1
0
-1

Hi Everybody

I'm developing a very simple DefaultApplicationPlugin used in a tool in my processes as a JMS Producer. In this plugin I have to pick the values filled in a form submitted just before the plugin is triggered. I know that this task is very simple using beanshell and form hash variables, but I'm looking for the equivalent accessors from Java code. 

Reading the documentation brought me to the FormDataDao, in particular I'm referring to this FormDataDao - Knowledge Base for v5 - Joget | COMMUNITY

But I'm not sure if it's the right approach, because how can I know which is the primary key of the just submitted form? Is there any other approach? Thanks


    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      According to the Process Tool plugin KB, a workflowAssignment object is passed as "workflowAssignment" property when it is available.

      To access it, just do this:

      WorkflowAssignment wfAssignment = (WorkflowAssignment) getProperty("workflowAssignment");

      Then, you can retrieve form data via AppService.loadFormData() utility method. See sample code:

      import org.joget.apps.app.model.AppDefinition;
      import org.joget.apps.app.service.AppService;
      import org.joget.apps.app.service.AppUtil;
      import org.joget.apps.form.model.FormRow;
      import org.joget.apps.form.model.FormRowSet;
      import org.joget.workflow.model.WorkflowAssignment;
      
      String formDefId = "hr_expense_new";
      String fieldId = "status";
      
      AppDefinition appDef = AppUtil.getCurrentAppDefinition();
      WorkflowAssignment wfAssignment = (WorkflowAssignment) getProperty("workflowAssignment");
      
      //Get record Id from assignment context
      AppService appService = (AppService) AppUtil.getApplicationContext().getBean("appService");
      String id = appService.getOriginProcessId(wfAssignment.getProcessId());
       
      //Retrieve data
      FormRowSet rowSet = appService.loadFormData(appDef.getAppId(), appDef.getVersion().toString(), formDefId, id);
      if (!rowSet.isEmpty()) {
          FormRow row = rowSet.get(0);
      
          //get field value here
          row.getProperty(fieldId);
      }


      References

      1. Francesco

        Thank you Chris, very helpful 

      CommentAdd your comment...