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.

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 that. So 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 will be a flow start and flow end here, which indicates the start and end of the workflow. And 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 are 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. 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. And there is no default value and you can leave some description if you want to here. So 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. And 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. 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 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 three and four if you want. But in our use case, branch one and branch two will be sufficient. And here we can add some components here. So the first component that we’re going to add is the assign task here. Assign task there and assign task here. So.
Assign task. Okay. And then we need to specify the condition on which this particular assigned task or branch one will be executed. So let’s open up the branch here. And go to the branch here and branch one and you specify the routing expression. So the easiest way to define your expression or 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. And if the value of the.
If the value of the state is equal to.
Then it will go the second branch route. Yes, click on done. 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 an 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. And we can say the adaptive form submitted to the workflow. And if you you would want to pre populate that active form here with the data submitted. Into the workflow. You would want to pre populate that active 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. And 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. OK. And then. We can go to the assign tab here. And we can associate assign these would be a specific user here. So in our case is going to be admin.
Administrator and 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. And 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. Form data. Yeah, it’s form data and same thing for the attachments. It will be pre populated with the attachments stored in the form attachments variable here. Assignee. 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. OK, and the other options I’m going to leave it as is and click on that.
So this creates our workflow very basic workflow and other important thing you want to do is in AM 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 AM forms cloud service instance. And we already have a video on how to configure and out of the box as your storage connector to use. Or enhance the capability of AM forms workflow to store the data in your Azure storage. So with that you save and close here.
And 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.