Using Form Data Model Service as Step in Workflow using-form-data-model-service-as-step-in-workflow

Starting with AEM Forms 6.4, we now have the ability to use Form Data Model as part of AEM Workflow. The following video walks thru the steps needed to configure Form Data Model step in AEM Workflow

Hi, in this video, we’re going to take a look at using Invoke Form Data Model Service as a step in AEM Workflow. So before we do that, let’s take a look at our sample Form Data Model Service that we have built to be used in this demo. So this service basically takes in a Social Security number and returns the credit score. So I’m going to test this out by providing a sample Social Security number and clicking on the test. It returns me a credit score. So now that our Form Data Model Service is up and running, the next step is to use it in our AEM Workflow. So for this purpose, I’ve built this simple workflow which gets triggered whenever a loan application form is submitted. So the first step in the workflow is to create a MetaData Property. And this is done using some custom code that I have written. And this is provided to you as part of the article assets. So this step creates a custom workflow MetaData Property called Social Security number and sets the value of that MetaData Property, by fetching the value from the Social Security number field, that was entered by the user, and submitted in the form.
So, once we set, the Social Security number MetaData Property, the next step is, to configure our Invoke Form Data Model Service. So the first thing we need to do is, to select the appropriate Form Data Model and select the appropriate service that you want to use. Next thing we need to do, is to map the input parameters, which the service expects. So as we saw earlier, the service expects a Social Security number and that Social Security number’s value is retrieved from the workflow MetaData. The output returned by the service is again, stored as a MetaData Property called Credit Score.
So now that our Invoke Form Data Model Service is configured, the next step that we do is, have or split operation here, where you can configure the routes based on the credit score returned by your Form Data Model Service. So I’ll quickly show you the two branches, that we had created here. Branch one, if the score is good credit score, meaning if the credit score is greater than 500, it goes this route. Or if the the score is a bad credit score, which is less than 500, it takes this route. So this is how you would use your Form Data Model Service in a workflow and use Conditional Logic to further process the result based on the values returned by the Firm Data Model Service. -

To test this capability on your server, follow the below instructions

![NOTE]In AEM Forms 6.5 and above this capability is available out of the box as describe here

  • Setup tomcat with SampleRest.war file as described here.The war file deployed in Tomcat has the code to return the applicant’s credit score. The credit score is random number between 200 and 800

  • Import the assets into AEM using package manager.The package contains the following:

    • Workflow model which uses FDM step.
    • Form Data Model that is used in the FDM step.
    • Adaptive form to trigger the workflow on submission.
  • Open the MortgageApplicationForm. Fill in the details and submit. On the form submission the loanapplication workflow is triggered.

workflow .
The workflow utilizes Or Split component to route the application to admin if the credit score is over 500. If the credit score is less than 500 the application is routed to cavery