Configuring Adaptive Form to trigger AEM Workflow

Prerequisites

The sample form used in this workflow is based on a custom adaptive form template which needs to be imported into your AEM server. The sample form that is provided needs to be imported after importing the template.

Get the Adaptive Form Templates

Get the sample Adaptive Form

The following video explains how to configure an Adaptive Form to trigger an AEM Workflow

Transcript
So now that our workflow is configured and complete, it’s time to trigger this workflow by submitting an adaptive form. But before you configure adaptive form with this workflow, make sure that your workflow is synced here by clicking on the Synced button. So let’s now take a look at the form that will be used to trigger that workflow. So this is our form here. Let’s open up its properties and make sure the form is configured to generate a document of record here by selecting this option. This option is important because our workflow will be generating a document of record, and we need to associate a template with this particular form. So make sure you have this option selected. The next thing we need to do is to configure that active form to trigger that workflow. So we open this form in the edit mode.
Go to its form container properties here.
And open up the submission tab here. and make sure the submit action is “invoke an AEM workflow.” There are a number of submit actions available to use, some are out of the box, and some of them here are custom. So select invoke AEM workflow, and select the workflow model here. “Review submitted data.” And the data file path is called Data.xml. Make sure this is the same name that you have specified in your workflow. So if you go to the workflow, and in the set variables we have used a file name called Data.xml while mapping the submitted data variable here. So we are saying that relative to payload, there’s a file called Data.xml. And in our form, we are saying save the submitted data in a file called Data.xml relative to the payload. So make sure these file names match. Since our form does not have any attachments or any document of record that we need to store, we’re going to leave them as blank. So the next thing we need to do now is to preview the workflow, preview the form, fill out some information, and hit the submit button to trigger the workflow. So let’s preview the form here. Fill out some information here.
Marital status is married, so the details are filled in. Then go to the income tab here. I’m going to fill in some values here.
Rental income.
I’m going to give a salary of, say, 2,000. So remember, our workflow will route based on the grand total. If grand total is more than 10,000 it will be routed to a particular person. If not, it will be routed to another person. Then in the assets tab, we can quickly do cash, say, 4,000. So now our form is complete. Let’s click on the submit button.
So when you hit the submit button, the workflow will be triggered and an appropriate task will be assigned to the user. So in our case, we are going to use administrator as the person to whom the task is assigned. So I have logged into AEM here in my AEM instance, as an administrator. And then this is the inbox where you see all the tasks. So click on view all, and here is a task which says greater than $10,000. And this was assigned a few seconds ago. So if I were to open this task, I see the form here. That’s the same form with the data repopulated from the submitted form here. So the data is all there. And if you notice, there are two action buttons here, approve and reject, because we configured our assigned task with these two actions and the icons are also showing up here nicely. There’s a check mark icon, and there’s a reject icon here. So if I click on the approve button here, the workflow will be completed, and it will go the route as we are defined in our workflow. So now my workflow is complete. So to see what steps your workflow did, you can go into the workflow models here.
Go into the workflow model, workflow, and go into the archive because our workflow is complete. So this is the workflow that was complete. And you can look at its history here. So the history was, these are the history and there’s greater than 10k generated a document of record because we clicked on the approve button. So the next video, we will take a look at how the data is stored and where the data is stored in the CRX repository. -

The following video shows you the workflow payload and other details in the crx repository

Transcript
So now that we have triggered our workflow from the Adaptive Form Submission, let’s take a look at what happens when a workflow is completed. So for that, I’ve logged into my AEM forms instance, I’ll go into the tools menu from there, go into my CRXDE Lite by clicking on this here. So this is my CRXDE repository. So from there, I’m going to go into the var folder, and in the var folder, there’s a folder called workflow. And in that workflow folder, expand instances, which lists the instances of the workflows. Under that there’s serve0, and under serve0, you’ll find a number of folders and each folder representing a date. So whenever you restart your server, it will create a folder for that particular day, and if you have restarted a server multiple times on a particular day, it will append the number. Therefore example here, 17_1, that means I started the server two times on that particular day. So go to the latest folder in that hierarchy, in my case, it’s 9-10. And under that, you will see the various workflow instances. So in my case, review submitted data is a workflow instance. Expand that folder. And under the data folder, you will see two notes called metadata and payload. So click on the metadata folder and look at its properties. So you’ll see a number of properties here, and some of these properties represent the variables and their values from the workflow. For example, grand total is a property that represents a variable from our workflow, and it has a value of 12,000. Similarly, submitted data is available with its value here. The value is the submitted data in an XML format, and then there’s a user action taken variable with the value approve. The next thing of interest is the payload folder. And in that folder, there’s a property called path and there’s a value here. So set copy that value and go to that value specified by the path here, copy and paste it here and here. So under here, this is the payload folder, under here, you will see two files. One is the data.xml that holds the submitted data. Because remember, when we configured our adaptive form to trigger the workflow, we asked the workflow engine to create a file called data.xml and store that file under the payload folder of our workflow instance. So that’s why you’re seeing a file called data.xml. And it contains the data that was submitted from the adaptive form. And here is there a DoR.pdf. So in our workflow, we had a step called generate document of record. And in that step, we specified to name or create a file called DoR.pdf, which will be the document of record and to place that file relative to the payload. So that’s our payload folder and under that you’ll see DoR.pdf. So this is the actual document of record that was created by the AEM forms workflow engine and stored here. So if you want to see this file, you can copy this part here, copy this part and go open up another tab here and paste it here, the part. So then it should download the PDF, which is the document of record. So this is the document of record that was generated here, right? So we did not customize this as a default document of record, but definitely you can customize this document of record. That will be part of another video or another article, but for now it’s suffice to say that we have been successful in creating a document of record from the data that was submitted using the workflow. So this concludes our course on creating a review and submit workflow and triggering that workflow from an adaptive form submission. -
recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e