Create an AEM Workflow

Create workflow model using AEM Forms workflow components. use Or-Split component to branch the workflow based on the value of the state variable.

 Transcript

So, after the form is created the next step we need to do is to create a workflow to handle the adaptive form submission. So, to create my workflow, I log into AEM go into the tools menu into the Workflow tab and drill down into the models menu here.

From the model menu here we can create our new workflow model give a meaningful title to our workflow model.

I’m going to call it review application, click on done.

Once the workflow is created open the workflow in the edit mode.

So, by default every workflow that you create will have a step one here and on the left-hand side are the various components that you can use to alter your workflow. And from here, you can also create the various variables that will be required in your workflow. Our workflow, we need two variables. So, let’s create those variables from here. The first variable will be called submitted data so that variable will hold the submitted data from the adaptive form submission. And since the submitted data from our form will be in a format of XML. We’re going to select XML data type. So, if your form is not based on adjacent schema or on a form data model type the submitted data will always be in an XML format. So, finish the creation of the variable here. And the second variable that we will create will be called total income.

And that variable will be of type double here. So, this variable will hold the total income of the user who has submitted the form here. So finished the variable creation. The next thing we need to do is to add a step which will initialize these variables that we just created. So, to do that, we’ll add a component called set variable in our workflow here. That’s the component called set variable that is out of the box.

We don’t need the step one component so we can delete that here. So, open up the properties of the set variable component and initialize the two variables that we have created. So, the first variable that we need to initialize is the submitted data variable here. So, we select the variable here. It’s called submitted data and the mapping mode is going to be relative to payload. So, what that, what we are seeing is, and the specific specified value is going to be data of XML. So, what we are saying here is there will be a file called data of XML relative to the payload of the other relative to the pay loader.

Once their active form is submitted and take the value of the data of XML, and map it to the submitted data variables. And then we need to initialize another variable the total income variable here. So, we select the total income variable And the mapping mode is going to be xpath.

And the excepted type of variable is going to be submitted data. And the xpath for that submitted for the variable is going to be this. So, what we are saying is take the value under the node total income which is residing under the data AF Unbound data in the AF data and put that value in the total income variables. This is because the submitted data from our adaptive form is going to be in an XML format and we are taking the value in the total income node and mapping it to the variable.

So, our data here is in this format: The first node is AF data, under that you have AF Unbound data, then the data and then we have the total income. So, we need to put an xpath expression pointing to the total income element and that’s what we have done here. So, if you see here, if you see here we have the total income and that the xpath is AF data, unbound data, data, and total income. So now that we have initialized the variables the next thing we need to do is to route the workflow based on the value of the total income. So, to do that, I’m going to add an or split component here.

So, it’s the or split component here and or split component has two branches based on the value of the total income the workflow will go either branch one or branch two. So, the first thing we need to do is to create a condition for the branch. So, open up the OR Split configuration properties here and go to the branches here. So, the first branch we’re going to select the rule definition here and click on add expression.

So, select your workflow variables here and drag and drop the total income field and select the operators.

If it is greater than, if the total income is greater than $5,000, you go this route, right? So we’ll do here and we can rename the branch one also here. So, we’ll do it. So we can say high income person In a similar manner, we would do a route for the branch to where if the total income is less than or equal to $5,000, we would go that route. So here we would do this.

And select operator is less than, less than $5,000.

And we add another condition here, OR, OR, sorry we can do is equal to $5,000. So, if the person’s income is less than or equal to $5,000, it will go that route. So that branch, we can rename it as low income individuals.

And then we can save our settings here. So, so this is, these are the two routes. We are different for a high income person. If it is more than 5,000, we go this route. If it is a low-income condition, we go this route. And then here we add to assign task steps here to assign tasks, steps here assign tasks. After adding the assign task component to each of the branches the next step is to configure the assign task component. So, I have opened assign tasks component by opening up this configuration sheet and I’m changing the title to high income. And in the forms and documents tab you have to select the type as an active form. And we are saying use the adaptive form that was submitted to the workflow.

And then we need to pre-populate the adaptive form with the data that was submitted by the user. So, for that, we’re going to select use an option variable and we need to select the variable that we had created that was going to be submitted data. What that means is use the data that was submitted to trigger this workflow and use the same data to pre-populate this adaptive form when it is opened in the assigned task component.

Then in the assigned task tab, we’re going to select the user to whom this particular task will be assigned. There are two options. Either you can assign a user dynamically or you can hard-code the user to whom this particular task will be assigned. So, from here, you can then select the users that you have. So, in my case, I’m going to select the admin user here. And then there are various options here which allow you to notify the user by sending him an email and other stuff. We’re not going to go into that right now. And then the actions that are available to the user when he opens the form through the inbox. So, these are the default actions. If you want, you can add additional actions by clicking on the add button here, and in the advanced tab here we can allow the user interacting with the tasks to be able to add the comments, attachments and other stuff, we’re going to accept the default settings and click on done. So, in a similar manner, then you would configure the the second assign task of your, of your branch. And then once you’re done configuring, click on the sync to create a run time model of your workflow. So now, your workflow is then ready to be associated with the form that you created, and you can configure the adaptive form to trigger this workflow when the adaptive form is submitted. -

On this page