Joget DX 8 Stable Released
The stable release for Joget DX 8 is now available, with a focus on UX and Governance.
Hi Tiensoon,
I have seen one of your post for fetching the workflow variable and you have mentioned that it can be achieved using Java api and provided the below code snippet,
import java.util.*; import org.joget.workflow.model.service.*; Collection list = new ArrayList(); WorkflowManager workflowManager = (WorkflowManager) pluginManager.getBean("workflowManager"); String usernames = workflowManager.getProcessVariable(workflowActivity.getProcessId(), "abc"); // get workflow variable value using Java API String delimeter = "|"; StringTokenizer str = new StringTokenizer(usernames, delimeter); while(str.hasMoreTokens()){ String temp = str.nextToken(); //System.out.println(temp); list.add(temp); } return list;
In the above code, i have a doubt
Please provide me the above clarification asap, so that it would be of very much helpful for completing a POC.
17 Comments
Tiensoon
That's an approach we can use to initialize WorkflowManager object in plugin.
Vignesh Balasubramanian
Hi Tiensoon,
Could you please provide a complete sample for initializing the WorkflowManager object by creating the PluginManager object and getting the workflow variable? Because I am getting an error in the initialization line saying pluginManager cannot be resolved, A sample code snippet would be of great help.
Thanks,
Vignesh
Tiensoon
Hi Vignesh, the BeanShell script you have gotten, is from the forum discussion of using BeanShell Plugin as a Participant Plugin. Are you using it for the same purpose too?
Else if you are mapping BeanShell Plugin to a system tool in a workflow, you could easily get a workflow variable's value in BeanShell script using Hash Variable. For example, this line of code will print the value of "testVar" workflow variable on console:
System.out.println("#variable.testVar#");
Vignesh Balasubramanian
Hi Tiensoon,
Im trying to integrate the Joget Workflow with an external application (the appln which im building), what I have did so far is,
I got stuckup in the approval stage while trying to retrieve the request details (workflow variables). But when i tried to persist the request data into a file instead of retrieving it from Joget engine im able to complete the whole process. But I dont want to persist the request details in file rather I would like to use the Joget's database (SQL) where Im struggling to retrieve the data.
Kindly help in this regard.
Thanks,
Vignesh
Tiensoon
Hi Vignesh,
Would like to get a clearer picture with your implementation.
I'm assuming that you have 2 activities:
Is the "Submit Details" form created with Joget Form Builder? Of is it an external JSP?
Vignesh Balasubramanian
Hi Tiensoon,
Yeah those were the two activities that I have defined for my workflow and submit details form is created with Joget Form Builder only, and the Request Approval activity will have a form with a Sub-form which will have the request details along with a radio button for approve or reject, these things I have defined in workflow engine and its working fine.
For the same functionality I am in process of developing an application which will have similar JSP pages in my application which will invoke the JSON API for accepting a request (with the details and then accept and complete), another set of JSPs for approving the request (which will invoke JSON API for accepting the req details and then complete).
To be more specific, I will have options for creating new request, view pending request. On choosing create new request I need to accept the request details from my JSP and on submitting, it will invoke the servlet which will call the CompleteWithVariable api call (
wflow-wfweb/web/json/workflow/assignment/completeWithVariable/
) and on submission its getting into Joget and I am able to view the request details from Joget console while i tried to approve the same request from Joget console, As a next step i want to populate the submitted details in my JSP for approving, this is where I got stuck up on how to proceed.
Kindly let me know if you need more details.
Thanks,
Vignesh
Tiensoon
If I got you right, you have 2 use cases.
First, you have tried using Form Builder to create forms for both the Submit Details and Request Approval activities. And since both of these forms are created with Form Builder, you have no issue with using Sub-Form to display requester's details in Request Approval form.
And in the second use case, you are trying to use external form (JSP) for the Submit Details and Request Approval activities.
If this is the case, the JSP of Submit Details could have saved the requester's data into your preferred database (not Joget Workflow's). And, the Request Approval's JSP could query from your database for the requester's details, right?
Vignesh Balasubramanian
Hi Tiensoon,
Yeah you are right, in my second use case Im currently just persisting the request details in a file and populating the data in the approval page, but I want to use Joget's internal repository itself for fetching the request details where it would get stored when we invoke the CompleteWithVariable API call. And I want to know the steps/procedure for accessing the same.
If you have implemented this, a sample code for accessing the same would be of greater help.
Thanks,
Vignesh
Tiensoon
If developing external forms on external Web platform, we usually recommend storing the data in your preferred external database. And pass decisional data (workflow variable) into Joget Workflow using JSON or JavaScript API, for transition routing purpose.
If if you would like to have external forms as JSP, and still would like to store the data in Joget Workflow database, perhaps you could insert the records directly into Joget Workflow database (create your own table) from the JSP, so that you could easily retrieve them in other subsequent forms?
Vignesh Balasubramanian
Hi Tiensoon,
I thought it would be better to use Joget Workflow database itself so that we can avoid another storage (external database) for storing and retrieving the data back which is again going to make another connection to this external database.
Anyway these data will get stored into Joget Workflow database on the CompleteWithVariable API call right?
In that case, I would like to know the way (a sample would be of greater help for me) in which we can retrieve the workflow variables from Joget's Workflow database. So that I would be able to show them in my subsequent forms for approval.
Or if you have any specific reason why we should go for external database when we are developing the external forms on external web platform? would be help me in understanding better.
Thanks,
Vignesh
Tiensoon
In that case, you can take a look at the shkactivities and shkactivitydata table in Joget Workflow database, for workflow variable value of an identified activity instance.
In some implementation use cases, the implementor might prefer to have external database to store business data; one of the reasons is to define ER for the tables/entities. But of course, this is case to case basis, and it's applicable for large implementation.
Vignesh Balasubramanian
Hi Tiensoon,
Thanks a lot for the information, I will look into those tables and get back to you if I face any issues.
BTW one more question :), by default these tables will be stored at localhost:3306/wflowdb right?
Thanks,
Vignesh
Tiensoon
You can check the database name by navigating to Settings > System Setup, and open the "Datasource and Profile Settings" tab
Vignesh Balasubramanian
Thanks a lot for the information Tiensoon, I will try this out and get back to you if in case of any issues.
Thanks,
Vignesh
Vignesh Balasubramanian
Hi Tiensoon,
The option you gave worked out, I directly queried the shkactivities and shkactivitydata tables and populated the request details in the subsequent forms.
Thanks a lot for your time and suggestion.
Regards,
Vignesh
Tiensoon
Hi Vignesh,
Glad to hear that. Feel free to blog (spread the words) about Joget Workflow if you find it useful for other people like you ;)
Vignesh Balasubramanian
Hi Tiensoon,
Yeah sure, will try to post a blog about my experience in using JoGet in near future. Will get in touch with you for any clarifications as well... :P