I've seen in many different posts requests for instructions on how to initiated a Forms business process from within a workflow and pass parameters. The responses have been to use HTTP requests, it's complicated, and future versions of Forms/Workflow will support this directly. These are all TRUE. ***Update - Current versions of Workflow and Forms have inbuilt activities to handle this*
Here are by step instructions on one way of doing it for Forms 9.2.1 and WF 9.2. Of note, this is not guaranteed to work in future versions of the Forms product and therefore is intended as educational or workaround use cases.
Background:
I wanted users to be able to right click on a document within Laserfiche and start a Business Process on an entry which would launch a Forms Business process instead of only a Workflow in order to take advantage of the user experience options in Forms. For this example, we'll pass one parameter, entryID into the forms process via the last WF activity.
Overview: We're going to setup 4 activities in WF. First to login to Forms, then to request the business process, grab a value from the response, then submit our form and initiate the business process.
Setup:
A.) If your forms process requires authentication in order to start, setup a Forms Account which has rights to start this process. For our example, we'll use Test as a Laserfiche Username and tester as the password.
B.) Setup a Webservice in workflow via Manage Webservices.
- Type: Custom
- URL: http://machinename (of Forms Application)
- Use Default Authentication
- Run activities that use this web service as a task
- Accept invalid certificates
Workflow Steps:
1: HTTP Post Activity
- Web Service is the one setup above
- URI: /Forms/Account/Login?returnUrl=%2FForms%2F (This assumes the full path to your Forms login page is http://machinename/Forms)
- Method: Post
- Form Data
- Username - Test
- Password - tester
- Click on the gear box to configure advanced options
- Check - Follow redirects
2. HTTP Web Request Activity
- Web Service - Same as above
- URI: {/Forms/jqm1L} This is the URL to your forms process when clicking on it from the green start icon from the Manage tab in Forms. jqm1L is my forms URL.
- Method: Get
- Click on the gear box to set advanced properties
- Request Cookies - Select, Set to the Request Cookies of the Login to Forms activity
- Check Follow Redirects
- Check Output new cookies container
3. Pattern Matching Activity
- New Token - Name it uqid
- Input - Set to the token "Content" from the Activity configured above.
- Pattern: (?:name="uqid" value=")([^"]*)">
- Check case sensitive
- If multiple matches are found, return: First match only
4. HTTP Web Request Activity
- Web Service - Same as all the others
- URI: /Forms/Form/Submit
- Method: Post
- Content Type: application/x-www-form-urlencoded
- Content Body: Field1=%(Entry ID)&action=Submit&formid=31&IsLocked=False&uqid=%(FindUQID_uqid)&routingResumeId=&stepid=1
- This is the trickiest part so I'll break it down. (*This is all one line)
- Field1 is the name of the input field given by Forms itself, not by you in the editor tools. It follows the schematic of if it's labeled Q1, then Field1 is what we want. If you want to set the parameter for the input field in Q4, then Field4, is what we want. In this case, I'm using the global token of entry ID to pass the entry ID of the workflow starting entry.
- Action = This is the name of the Submission button at the bottom of the form configured from the process modeler. If it displays something other than Submit, you'll have to change it to that name.
- FormID = This is the FORMS ID, not the Business Process ID in forms. To find this, edit the starting form in the Forms editor and notice the URL. The number at the end is the FormID. http://machinename/Forms/design/layout/31
- uqid = pass it the token from the pattern matching activity, this is a unique id generated at the time of display of the submission form
- Leave isLocked to false, routingResumeID to null, this deals with the saving, resuming later feature I believe
- Leave stepID to 1.
- Click advanced Tab
- For request cookies, select the cookies from the previous HTTP Request activity.
- Check Follow redirects
Done!
One can test the requests at each step but note if a login is required prior to starting the business process the last two activities will not work. So make it public first, make sure everything works, then make it restricted and test again by launching the whole Workflow.
Lastly, be mindful of your workflow security as this setup has the Forms account credentials in clear text within the workflow definition. Anyone who has the right to download and view the workflow activities will also have access to these credentials.
Cheers,
Carl