AEM Forms · updated

How the AEM Forms rule editor works for core component forms

The rule editor is a visual tool for adding behaviour to a form: show or hide a field, enable or disable it, set or validate a value, or call a service. A rule is a condition plus one or more actions. On Cloud Service there is no code editor; custom logic goes into custom functions that rules can call.

In plain words

A rule reads like a sentence: when the visitor chooses 'Other', show the 'Please describe' box. Business users can write most rules themselves. Developers add reusable functions for anything the built-in choices do not cover.

What a rule can do

  • Show or hide an object
  • Enable or disable an object
  • Set a value for an object
  • Validate the value of an object
  • Run a function to compute a value
  • Invoke a Form Data Model service
  • Set a property of an object

Rule types and the two shapes of a rule

ShapeRule typesUse it when
Condition, then actionWhenOne condition should trigger several actions, or the action should run as soon as a value changes
Action, then conditionShow, Hide, Enable, Disable, Set Value Of, ValidateOne action depends on several conditions

For Show and Enable the alternate action is fixed: Show falls back to Hide and Enable to Disable, and the other way round. The editor only offers the rule types that make sense for the selected object; a panel, for example, has no Validate or Set Value Of.

Who can do what

Adobe states that users in the forms-power-users group can create scripts and edit existing ones, while users in the forms-users group can use scripts but not create or edit them.

What changed from AEM 6.5

Adobe's list of differences says Cloud Service provides a hardened rule editor and that the code editor is not available. The Migration Utility converts rules written in the code editor into custom functions. The onSubmitError and onSubmitSuccess functions are available as actions in the rule editor.

How to write a rule that stays maintainable

  1. Decide which field the rule belongs to: Adobe's rule of thumb is to think from the object you are writing the rule on.
  2. If one condition drives several fields, write one When rule on the field being checked rather than a Show or Hide rule on each target.
  3. If one field depends on several conditions, write a Show, Hide or Set Value Of rule on that field.
  4. Move repeated logic into a custom function and call it from the rule.
  5. For values filled in on the server, such as prefill, use a When rule that runs when the field is initialised.

Related tools and pages on this site

Questions

Is the code editor available on AEM Forms as a Cloud Service?

No. Adobe states the code editor is not available on Forms as a Cloud Service; custom functions take its place.

Can a rule call a back-end service?

Yes. A rule can invoke a Form Data Model service and use its output, for example to fill several fields from one lookup.

What rules can a spreadsheet form on Edge Delivery Services use?

Adobe's comparison lists them as limited: show or hide, compute a value, and custom functions. In the sheet these are the Visible Expression and Value Expression columns.

Sources

Facts about Adobe's products on this page are from the linked Adobe pages, read on the date shown beside each. Explanations, steps and examples are ours unless marked as Adobe's. If Adobe's page and this one differ, Adobe's page is right.

Surge Migrate is not affiliated with Adobe and claims no Adobe partner status. Adobe product names are trademarks of Adobe.

Surge Migrate

Moving the website itself

This page answers one AEM Forms question. Surge Migrate moves a website from any CMS to any CMS. Converted automatically. Checked before you install.

  1. 1

    Scan

    Names the system behind your site, counts pages and templates, lists the blocks to build and the work no tool does, and gives an effort range with its working.

    Scan a site →
  2. 2

    Convert

    Each page becomes an Edge Delivery document, an AEM Core Component page and import files for 7 other systems. 10 pages free; 500 or 2,000 pages in one paid run.

    Convert your pages →
  3. 3

    Verify

    A download is offered only when its own format check passes. The report lists every field not found and every component kept as plain content. Compare old and new pages side by side.

    Parity check →
  4. 4

    Install

    You import with the target system's own tool, on your own environment. Each download's README gives the command. Your system changes only when you run it.

    How each import was tested →