Creating Computed Form Data Model Elements in AEM Forms creating-computed-form-data-model-elements-in-aem-forms

Computed form data model elements allow you to store the manipulation result on one or more form data model elements. For example, you may want to calculate and store the monthly salary by performing a mathematical operation on the salary field. To do this you will divide the salary by 12 and store the result in computed form data model element called monthlySalary.

Another example for creating computed form data model is to concatenate two or more form data model elements. For example, you can concatenate state and zip form data model elements with a hyphen between the two elements.

The following screenshot shows you the computed elements StateaandZip and monthlySalary

computedfdmelement

Creating monthly salary computed element

Transcript
In this video, we’re - gonna take a look at creating Computed Form - Data Model element. A Computed Form - Data Model Element is typically used to store - the result of manipulations by Form on one or more - Form Data Model Elements. For example, we have this - account holder table, which has various - columns. For instance, it has a column - called Account Number, First Name, Last name and it - has a column called Salary. So this Salary is used - to store the annual salary of this particular - account holder. If you now want to get a - Computer Data Model Element, which will store the - monthly salary, we will create a new element, by selecting the Form - Data Model Element and creating a - type of property.
We’ll call it Monthly Salary and since this is going to - be a computed element, we select this checkbox and set - the appropriate type to Float and then we do - “done” to save this newly created Form - Data Model Element. Then, we need to - populate the value of this newly created - Data Model Element by creating a rule. To create the rule, we select - the Form Data Model Element, which is Monthly Salary and click on - the Edit Rule. We then click on the Create button - to bring up the Visual Rule Editor. Here, we can manipulate or set the - rules of the Monthly Salary field. To set the value of the Monthly - Salary, we select an option here, to Mathematical Expression. Then we will select - the appropriate elements on which we - need to manipulate. So we select the - Salary here.
Set the operator - to Divided By and then we set its - value to a Number, and that is going - to be right. So what we have done, is created - a Form Data Model Element, called Monthly Salary and set its value to the Number Salary divided by - twelve to get its Monthly Salary. So now you’ll have a - monthly salary element, which can then be used as any other - Form Data Model Element within your AEM form. So we save this and to test the newly created Form - Data Model Element is working correctly as expected, we - do test model object here. Save and then, we do a test - model object here. So we enter the - account number and then do a test here. So as you can see here, the salary is ninety - six thousand and the monthly salary - is eight thousan. which is a correct - value, since we divided the salary of ninety six - thousand by twelve, to get this monthly salary. So this way way, you can create Computer Data - Model Elements by performing some mathematical or - string operations on existing Data - Model Elements. -

Creating StateandZip computed element

Transcript
In this video, we will create a - Computed Form Data Model Element by captivating one or more - Form Data Model Elements. To create a Computed Form - Data Model Element, we select the - Data Model. Click on Create Child Property, - set its name to StateandZip and select that computer - option and set a type to String.
So now, we have created a - Computed Data Model Element, but we need to set its - value by creating a rule. To create a rule, we select the newly created - Data Model Element and click on Edit Rule. Click on Create and we - need to set a rule. To set a rule, we can - either set a String or a Mathematical Expression. So here, we’re going to select - Mathematical Expression. Since we are going to - calculate one or more Form Data Model Elements, we need to drag and drop the - appropriate Data Model Elements. To do that, first - we drop the state Form Data Model Element here. We select an operator here, Plus - and we select a String here, and reset its value - to a hyphen.
Since we need to cut State - and Zip Elements, separated by a Hyphen, we need to expand - this expression, here so, that now we have - another Operator to select. So we then select a - Plus operator and then drag the Zip - Element onto this here So what we have done, is created - a new Form Data Model Element, which is the result - of State and Zip with the hyphen between - these two elements. So we then do “done” and close its value - and Save this. Now to test this newly - created Data Model Element, we select the Data Model and - click on Test Model Object. We need to provide a valid account - number, so that it fetches the results from the - underlying Data Model. Click on Test. So now you see here, the - StateandZip it does show correctly, there’s a state of California, with - the hyphen and then there’s a Zip. So this is how you would create - a Form Data Model Element by calculating one or more - existing Form Data Model Elements. Now, this Form - Data Model Element can then be used as any - other Data Model Element within your AEM Forms. -
recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e