Create an AEM Workflow
Last update: Sun Mar 23 2025 00:00:00 GMT+0000 (Coordinated Universal Time)
- Topics:
- Adaptive Forms
CREATED FOR:
- Beginner
- Intermediate
- Developer
AEM Forms as a Cloud Service
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
In this video, we will create a review workflow in AMForms Cloud Service Environment. So I’ve logged into my AMForms Cloud Service Environment. I’ll go into the tools menu here and go into the workflow, and from here, drill down into the models card. From here, you can create your workflow models. So to create my new workflow, I’m going to click on the create button here and click on create model, give a name to the workflow. I’m going to call it review workflow and click on done. The workflow model is created. Now we can go ahead and edit the workflow. So every time you create your new workflow model, at the minimum, you’ll have a step one, and then there’ll be a flow start and flow end here, which indicates the start and end of the workflow. On the left-hand side are the various components that AM provides you out of the box. In our case, we are concerned with the components under the forms workflow category, and these are the components that are available in the AMForms Cloud Service instance. So the first thing we need to do is to create some variables to hold the data when an adaptive form is submitted. So the first variable we’re going to call is the form data, and the type is going to be of XML because our adaptive form is not based on any form data model. It could be based on a schema or not. So hence, the data will be in an XML format. You can associate a schema with that XML variable here, but in our case, we’re not going to do that. So click on to create your variable. The next variable would be to store the attachments associated with the form. So we’re going to call it form attachments, form attachments, and the type is going to be of ArrayList and the subtype is going to be document, and then we save this variable. The third variable we’re going to create is called state, and that variable will be of type string here. There is no default value and you can leave some description if you want to here. So far, we have created a workflow model with three variables. Now, the first thing we need to do is to initialize the variables that you have so that you can use it in your workflow later on. So the first thing we need to do is to add a component called set variable here. So add a set variable component here, and you can delete the step one. We don’t need the step one here, so you can delete the step one. So the set variable allows you to initialize the variables that we created earlier. So let’s go ahead and do that first. So the first thing we need to do is to initialize the state variable here, so the map, and you have to select a variable called state. How do you want to initialize that? So here I’m going to do XPath. So whenever you are selecting a mapping mode which is XPath, you need to have an XML document here or XML variable, so that’s form data, and then you can specify the XPath expression here. So the XPath expression here drills down into the state element of the XML data that is submitted from your adaptive form. So the structure is AF data, AF unbound data, data, and state. Because our adaptive form is not based on a schema, the entire data that is captured in the form will be under the unbound data node and under that there will be a data node, and under that there will be this state element here. So now we click on that. So now our state variable is initialized. The next thing we need to do is to do a branching based on the value of the state variable. So to do that, let’s add a branch here or a or split. It’s called or split here. It’s called or split, and there are two branches. If you want, you can add extra branches like branch 3 and 4 if you want, but in our use case, branch 1 and branch 2 will be sufficient. Here, we can add some components here. So the first component that we’re going to add is the assigned task here. Assigned task there and assigned task here. So assigned task. Then we need to specify the condition on which this particular assigned task or branch 1 will be executed. So let’s open up the branch here and go to the branch here, and branch 1, and you specify the routing expression. So the easiest way to define your expression or a routing expression is by selecting the rule definition here, and click here to open up the graphical user interface to define your expression here. So here we’re going to say, if the value of the state variable is equal to string, and that string is going to be CA. So if the value of state is equal to CA, then the workflow will go this particular route. If the value of the state is equal to say Arizona, Arizona, then it will go the second branch route. Yes, click on Done. Let’s say, then it will go on the second branch. So here we need to configure the assigned task properties. The assigned task is nothing but a user step in the workflow, which will allow a user to interact with the particular task or the form that is submitted to this workflow. So click on Configure, and give a title here. You can call it CA applicants here, and the form or the document associated with this particular task is going to be an adaptive form. We can say the adaptive form submitted to the workflow. You would want to pre-populate the adaptive form here with the data submitted into the workflow here. So for that, we’re going to select a variable here, and the variable would be form data. Then if you would want to have the attachments associated with the form to show up here, we can say variable, and that variable would be form attachments. Then we can go to the Assign Me tab here, and we can associate. Assign Me would be a specific user here. So in our case, it’s going to be admin, administrator. The default options, you can leave them as is. If you want to change, you can read the documentation and find out what each of these options mean and change it accordingly. But for now, we’re going to just leave it as is. Done. In a similar manner, we can change this branch to assign task here. So here we can call it Arizona applicants. Same thing for forms and documents here, adaptive form submitted to the workflow, and it’s going to be pre-populated with the data that will be stored in the variable called form data. It’s form data. Same thing for the attachments. It will be pre-populated with the attachments stored in the form attachments variable here. Assign Me, you can either assign it dynamically to a user or a group, or you can hard-code it to a particular user. In our case, for the purpose of simplicity, I’m going to assign it to the same user here, admin. The other options, I’m going to leave it as is and click on Done. So this creates our workflow, very basic workflow. Other important thing you want to do is, in AEM forms Cloud service, you can now externalize the storage of your workflow. So for that, you can open up the properties here, and click on externalize workflow data storage. That means the workflow data, which includes the variables, the attachments associated with the workflow will be stored in an external data storage outside of AEM forms Cloud service instance. We already have a video on how to configure an out of the box Azure storage connector to use or enhance the capability of AEM forms workflow to store the data in your Azure storage. So with that, you save and close here. Now your workflow is complete. Make sure you click on the Sync button. In the next video, we will see how you can configure an adaptive form to trigger this particular workflow.
recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69