Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Variable not being included in XML data file output


Level 4
This seems like it should be obvious, but I've struggled with this for a couple of days.

As a programming principle, I like to make the form as "smart" as possible and the resulting Word templates, or XML documents as simple as possible. I need to be able to set a "flag" that would be in the XML data file if certain conditions are met, e.g.,

if (field1.rawValue == "0"){variable1 == "1"};

if (field2.rawValue == "0") {variable1 == "1"}; etc.

The problem that I'm having is that I can't seem to get variable1 to be included in the XML data file that the form creates.

Help! This seems like it should be so simple but I'm baffled.

1 Reply


Former Community Member
The variable you're setting does not fall within the scope of the xml output (it's scope is only within the execution of the form).

Try creating a variable (Using File > Form Properties >Variable) and assigning your value to it (variableName.value = 1).

One note of warning, you'll want to trigger the validation event every time the form is opened or your value will return to the default value when users re-open the form.