JSON Forms

IN THIS PAGE

Description

JSON Forms allow you to create complex, data-driven forms using a single control on a UX Component, rather than adding individual controls for every field. They are lightweight, fast, and can be defined using JSON data.

JSON Forms are a control type (introduced in v4.6.5.0) that you can add to a UX Component. JSON Forms appear in the UX Builder toolbox in the Data Controls section of the toolbox.

JSON Forms are an alternative to adding individual controls to a UX. For example, before JSON Forms were introduced, if you wanted a UX component with these input controls, FirstName, LastName, Address, City and State, you would add 5 individual textbox controls to the UX.

However, using JSON Forms you can add a single control to the UX (a JSON Form control), and then you can edit the JSON Form control and add FirstName, LastName, Address, City and State input controls to the JSON Form.

The advantage of this approach is that the UX is much lighter weight (it has 1 control vs. 5 controls) and it is extremely fast. This advantage becomes more pronounced the more controls you have on a UX.

Another benefit of JSON Forms (besides being extremely light weight and fast) is that the form definition can be composed using either server-side code (for example, Xbasic, Python, Node.js), or client-side (JavaScript).

You can also store form definitions in a database.

The JSON Form control shown in the UX Builder toolbox under Data Controls.
JSON Form control in the toolbox

UX Component - Login - JSON Form

The sample UX Login component has been rebuilt using JSON Forms. When you create a new login component from a UX you have the option of using individual controls for the login controls, or using a single JSON Form for all of the login controls.

The Login Component Style dialog showing the option to use a JSON Form.
Login Component Style

If you choose to use a JSON Form the resulting UX component has significantly fewer controls (as shown in the image below).

The UX Builder showing a login component built with a single JSON Form control.
Login Component using a JSON Form

A UX login component built with individual controls has many more controls than the same component built using a JSON Form (as shown in the image below).

The UX Builder showing a login component built with multiple individual
                    controls.
Login Component using Individual Controls

Working with JSON data

The reason that JSON Forms are considered to be a Data Control is that, like all other Data Controls, you can use the .getValue() and .setValue() methods to read and write the value in a JSON Form control.

The JSON data in a JSON Form is in JSON format and the definition of the JSON Form is also in JSON format, hence the name of the control type.

For example, consider a simple UX with a basic JSON Form that looks like this:

A simple JSON form rendered in the UX.
Simple JSON Form

Always Submit Value Property

A new property is available for controls to ensure that the control submits a value even if the data in the control has not been edited. By default, the JSON form will only submit a value for a control if the control is dirty.

When this property is checked, a value for the control is always submitted.

The Always submit value property checkbox in the JSON Form builder.
Always Submit Value Property

Submit Component with Client-side Errors

A new property, Submit component even if has client-side errors, controls whether the UX component submits when validation errors exist.

The default value for this property is now .f.. Validate code in JSON form controls is evaluated to determine if there are client side errors.

The Submit component even if has client-side errors property setting.
UX Validate Property

Include Property

All controls in JSON forms now have an Include property. The Include property is similar to the Show/hide property in that it can be used to show and hide controls.

The difference between the Show/hide property and the Include property is that if a control's Include property returns false, the control is not rendered at all.

In contrast, if a Show/hide property returns false, the control is rendered, but it is not displayed. When the UX is submitted, the JSON data that is submitted will include a property for all hidden controls, but will not include any controls that are not included.

The Include property setting in the JSON Form builder.
Include Property

JSON Form definition example

The definition for this JSON Form is:

[
    {
        "type": "edit",
        "id": "TEXTBOX_1",
        "data": {
            "from": "First_Name"
        },
        "label": {
            "text": "First Name"
        }
    },
    {
        "type": "edit",
        "id": "TEXTBOX_2",
        "data": {
            "from": "Last_Name"
        },
        "label": {
            "text": "Last Name"
        }
    }
]

Reading values

When you read the data from the above JSON Form (using the .getValue() method), it might look something like this:

{"First_Name":"Fred","Last_Name":"Smith"}

Reading values from individual controls

When you use the .getValue() and .setValue() methods on a JSON Form you are working with JSON data. However, the .getValue() and .setValue() methods can also be used on individual controls in the JSON Form.

For example, in the simple JSON Form above (which has a First Name and Last Name control), if you were to execute this method:

var val = {dialog.object}.getValue('FORM1')

The value in val might be something like:

{"First_Name":"Fred","Last_Name":"Smith"}

But say you wanted the value in the last_name variable, you could use the .getValue() method as follows:

var val = {dialog.object}.getValue("JSONFORM::Form1::last_name")

Setting Values and Dirty State

When you use the .setValue() method to set the value of a control in a JSON Form using the JSONFORM:: syntax, the JSON Form does not automatically go dirty.

There is an optional parameter that can be set to true to force the JSON form to go dirty.

{dialog.object}.setValue('JSONFORM::JForm1::FirstName','Fred',true);

Control name syntax

The syntax for the control name for both the .getValue() and .setValue() methods is:

JSONFORM::form name::variable name

The form name is case insensitive, but the variable name is case sensitive.

The JFORM prefix can be used as an alternative to JSONFORM.

How to build a JSON Form

To add a JSON Form to a UX component, select the [JSONForm] item from the toolbox.

JSON Form toolbox item
JSON Form toolbox item

This will add a blank JSON Form to the UX component.

Blank JSON Form added to a UX
Blank JSON Form added to a UX

Then either double-click on the item in the list of UX controls, or click the smart field for the JSONForm properties property in the Property Grid.

Opening JSON Form properties
Opening JSON Form properties

This will open the JSON Form builder. You add controls (called items) to the JSON Form in much the same way that you add controls to a UX component.

JSON Form builder
JSON Form builder

To add a control (i.e. item) to the JSON Form, click the Add Item button. This will open a dialog where you can select the control type to add.

Select Control Type dialog
Select Control Type dialog

Control type categories

The Select Control Type dialog is divided into sections. The Data Controls section shows all of the controls that are bound to JSON data. These controls can be used to set values in the JSON data created by the JSON Form and to display data values.

The Other Controls category allows you add buttons, HTML, images and custom controls (where you define the control by entering its JSON definition).

Other Controls section
Other Controls section

The Containers section allows you add different types of containers to your JSON Form. Containers are used to control the layout of the JSON Form.

Containers section
Containers section

New Container Options

New Container Options: Two advanced container controls have been added: FreeFormLayout and CSSGrid.

These allow for pixel-perfect control over your form layout using HTML templates or CSS Grids.

See Also

The Pre-defined Controls section allows you to add controls that are designed for a specific purpose.

For example, the [List Detail-View Buttons] control will add several buttons to a JSON Form that is being used as the Detail View for a List to save edits made in the JSON Form back to the List, to synchronize the List, etc.

List Detail-View Buttons control
List Detail-View Buttons control

You can add any control type to the Favorites section by right-clicking on the control and then selecting Add to favorites. To remove a control from the Favorites section, right click on the control in the Favorites section and select Remove from favorites.

Favorites section
Favorites section

Another way in which you can create a JSON Form is by using the Quick start genies.

Quick start genies link
Quick start genies link

Using the Quick Start Genie

When you click on the Quick start genies hyperlink, the following dialog is displayed.

JSON Form quick start genie dialog
JSON Form quick start genie dialog

The Genie offers several types of quick starts. These are:

  • Create form from sample JSON Data

    This option allows you to enter sample JSON data and to create a form that can be used to create or edit JSON data in the same shape as the sample JSON data. The sample JSON data can include nested arrays.

  • Quick Input

    This option allows you to enter a list of form controls and optionally specify the control type for each control (if you don't specify a control type, the control will be a textbox).

  • Create Form based on List Data

    This option allows you to select a List control in the UX and automatically build a JSON form to match the data structure of the List's data.

  • UX Data Binding

    This option applies when the UX is data bound.

  • Quick Dialog - Xdialog Format

    This option allows you to convert Xdialog syntax into a JSON Form.

Quick start example
Quick start example

Using the Real-time Preview window

When you are in the JSON Form designer you can open a Preview window to preview your form layout. The Preview window is modeless, which means that you can keep it open while you continue to work on your form design.

The Preview window is also hot - meaning that if you click on a control in the Preview window the focus in the Property Grid will move to the selected control. If you change a property value in the Property Grid, the Preview is automatically updated.

Save JSON Forms to repository

When you are in the JSON Form designer, you can save the form to the Repository (the Repository is a table in a SQL database). You can configure the Repository by going to the Project Settings dialog.

Once you have saved a form definition to the Repository you can load a form from the Repository.

To save a form to the Repository, click the More.. button and select Save JSON form definition in Repository.

Saving a JSON form definition in the Repository
Saving a JSON form definition in the Repository

Load JSON Form from repository

You can load a form into the JSON Form designer from the Repository by clicking the More.. button and selecting Load JSON form definition from Repository.

Load JSON Form from Repository (Action Javascript)

At run-time you can load a JSON Form definition from the Repository into a JSON Form control in the UX. To do this, select the JSONForm Control Action when you define an Action Javascript action.

JSONForm Control Action
JSONForm Control Action

Then select the Load a saved form definition from the Repository action, and specify the target JSONForm id and the Saved form name.

Load from Repository action settings
Load from Repository action settings

Understanding the Layout Property

Every control in a JSON Form has a Layout property that controls how the different parts of the control (i.e. the control itself, its label, its help text, etc.) are rendered. The JSON Form builder has a number of different pre-defined layout styles. You can also create your own named layout styles.

For example, in the image below, the label for field1 is shown above the control, the label for field2 is shown below the control and the label for field3 is shown to the left of the control.

Examples showing different label placements for fields in a JSON Form layout.
Layout Examples
The Layout property settings for a JSON Form item.
Item Layout Property

When you click on the smart field for the Layout property, a dialog is opened showing all of the available named layout styles. The styles shown in green are the system styles and they cannot be edited or deleted.

The styles shown in blue are the user-defined styles.

A dialog showing available named layout styles, including system and
                    user-defined styles.
Layout Styles Dialog

To add a new named layout style, select the <ad-hoc> option and then click the Edit button. The builder for the layout definition will then open.

There are two ways to define a new layout:

Simple

Define an HTML template with placeholders for different control parts.

Javascript

Javascript code.

The builder for the Simple mode is shown below.

The Layout builder in Simple mode.
Layout Builder - Simple Mode

The builder for the Javascript mode is shown below:

The Layout builder in Javascript mode.
Layout Builder - Javascript Mode

Embedding Controls in a JSON Form

You can embed standard UX Controls within a JSON Form. For example, you might have a ViewBox control that you would like to embed in a JSON Form.

To embed a UX control in a JSON Form, edit the JSON form and add an [Embedded] control (from the Data Controls section in the dialog that appears when you click the Add item button) at the location in the form where you want the embedded control to appear.

Adding an [Embedded] control to a JSON Form.
Embedded Control Item
Configuring an embedded control in a JSON Form.
Embedded Control Configuration

Then specify the id of the control you want to embed by clicking the smart field for the Control id property.

Selecting the Control id for an embedded control.
Select Embedded Control Id

When you use .getValue() to get the value of a JSON Form, the embedded control's value is included in the JSON for the JSON Form's value. Similarly, when you use the .setValue() method to set the value of a JSON Form, the value of any embedded controls will also be set.

Display Format

You can define a Display Format for a field in a JSON Form. When the control has focus, the raw data in the form is shown. When the control loses focus, the formatted value is shown. For example, in the images below the formatted date is shown for the n3 field. In the second image, the raw value in the field is shown.

A field showing a formatted value when it does not have focus.
Formatted Value
A field showing the raw value when it has focus.
Raw Value

The following types of Display Formats can be defined:

Character
Numeric
Date
Friendly date
Custom

When you select the Custom option you can define Javascript code to return the formatted value. Your Javascript code can reference the raw data in the field.

For example, you might define the following Javascript code to add a leading $ to the value in the field:

return '$' + v

Auto-suggest and Edit Combo Picklists

The picklist that is displayed for Auto-suggest and Edit Combo controls can now be based on a SQL expression. This allows you to display data from more than one field in the picklist.

For example, if you set the Display field property to:

expn:concatenate(City,', ',Country)

The picklist will display data from the City and Country fields.

The expression is defined using Portable SQL syntax.
Change in Behavior: When defining an expression for the Display Field, you must now prefix the expression with expn:.
The Display field property showing the expn: prefix.
Display Field Expression Prefix

Textbox Controls - In-Control Buttons

You can define in-control buttons for textbox controls and all control types that derive from textbox (e.g. edit-combo).

The Custom in-control buttons property in the JSON Form builder.
Custom In-Control Buttons Property

To define in-control buttons, check the Custom in-control buttons property and then click the smart field for the In-control buttons definition property.

This will open a dialog where you can define the buttons. You can place the buttons at either the left or right edge of the control, and the buttons can be either an icon or HTML text.

The dialog for defining in-control buttons.
In-Control Buttons Definition Dialog

The image below shows a textbox control with an in-control button (an icon) on the right edge of the control.

A textbox control showing an icon button on the right edge.
Textbox with In-Control Button

Styling Choices for Picklists and Groups

You can now specify a style and classname for the choices displayed by edit-combo, auto-suggest, RadioButtonsGroup, and CheckBoxesGroup controls.

The style or classname can be specified by a function that returns different class names or styles, depending on the data.

For example, you might enter the following value for the style to show the label for Monday in red:

{javascript}function(d) {if(d.html == 'Monday') return 'color:red'; else return 'color:purple;'}

Notice that the function must be prefixed with {javascript} and that the function takes d (an object with an html and value property) as an argument.

Defining styles for choices in the JSON Form builder.
Defining Choice Styles
A picklist showing styled choices based on data values.
Styled Picklist Example

Fill-in Fields for Edit-combo and Auto-Suggest

When you define fill-in fields in an edit-combo or auto-suggest control, you can now fill in fields in a JSON Form.

Configuring fill-in fields for an edit-combo or auto-suggest control.
Fill-in Fields Configuration

Placeholders

You can now define placeholders for textbox, dropdown, edit-combo, and auto-suggest controls. The placeholder text can be styled by specifying a class name or a style.

The properties for defining placeholder text and style in the JSON Form
                    builder.
Defining Placeholders

The image below shows a textbox control with some placeholder text, styled to appear in blue. As soon as the user starts typing into the field, the placeholder text is removed.

A textbox showing styled blue placeholder text.
Placeholder Text Example

Integer-Step Control Enhancements

Additional functionality has been added to the Integer-Step control.

You can now:

  • specify that the user can type a value into the control (previously you had to use the increment/decrement buttons)

  • specify a minimum and maximum value

  • specify an increment value (the amount by which the value is changed when an increment/decrement button is clicked).

To set these properties of the Integer-Step control, edit the JSON form, select the Integer-step control and navigate to the Other Properties section of the properties grid.

The Other Properties section for an Integer-Step control showing min/max and
                    increment settings.
Integer-Step Control Properties

Date Picker Control Icons

You can now control if a datepicker control should have an icon to open the datepicker. If no icon is shown, clicking anywhere in the control will open the datepicker. If an icon is shown, you can customize the icon.

Datepicker control with no icon.
Datepicker with No Icon
Datepicker control with default icon.
Datepicker with Default Icon
Datepicker control with custom icon.
Datepicker with Custom Icon

To set the properties of the datepicker icon, set the properties shown below.

If you have turned on the Show Icon property, you can leave the Icon Name property blank to use the default icon.

Properties for configuring the datepicker icon.
Datepicker Properties

RadioButtons, Checkboxes, and Groups

JSON Forms now support three additional control types: RadioButtonsGroup, CheckboxesGroup, and RadioButton.

The RadioButtonsGroup and CheckboxesGroup controls allow you to define a radio button or checkbox control and also specify the choices for the control.

The choices can be static or dynamic. If dynamic, you can specify a SQL query, an Xbasic function, or a Javascript function.

The controls in the group can be laid out horizontally, vertically, or in multiple columns.

Individual RadioButton Controls

The RadioButton control is a single control. It does not have choices. Instead, you must specify the label for each individual control in the Radio Button HTML property.

You can insert as many RadioButton controls into the JSON form as you require. The individual RadioButton controls will behave as a RadioButtonsGroup control as long as you specify the same variable name for each control in the group.

When you define a RadioButton control, you must specify the value that the control will return when selected. The value is set in the Value property in the RadioButton Properties section.

In the image below, the radio buttons for Pick a day are in a RadioButtonsGroup control and the choices have been defined as a static list.

Note also that the radio button for Monday is red. This was done by setting the Choices data style property to this Javascript function:

{javascript}function(d) {if(d.html == 'Monday') return 'color:red'; else return 'color:green;'}

The Married and Single radio buttons are individual RadioButton controls. They behave as a group because they use the same variable name.

Notice that the RadioButtons in this group are separated by the Pick a day control. This is possible because you have the ability to place the individual RadioButton controls at any location on the JSON form.

For example, the value for the Married radio button might be set to married and the value for the Single radio button might be set to single.

A JSON Form showing a RadioButtonsGroup and individual RadioButton controls
                    sharing a variable.
RadioButtons and Groups Example

Action Javascript

The JSONForm Control action in Action Javascript offers a number of actions.

JSONForm Control action options
JSONForm Control action options

Data Binding

When you create a UX component you can specify that the UX is databound. This allows you to define how fields in a SQL database are bound to controls on the UX.

You can then navigate through the records in the database and make edits to the values shown in the UX and then, when you click the Submit button, your edits are applied to the database.

By default, when you bind a UX to a database, you define individual controls for each field in the SQL table. However you can also use a JSON Form for Data Binding.

See: Data Binding Video

Using the JSON Form Tester

The JSON Form Tester window allows you to experiment with the JSON definition of a JSON Form to see how the form will render.

See: JSON Form Tester Video

Multiple Layouts

Like Lists, ViewBoxes and ControlBars, JSON Forms can have multiple Layouts.

You can use Action Javascript to switch layouts. Select the Selection layout action in the Action type for the JSON Forms action.

Selection layout action
Selection layout action

The JavaScript to change layouts is shown below:

var obj = {dialog.object}.getControl('JFORM1'); // get a pointer for JFORM1
obj.uxSelectLayout('DEFAULT');

Paginated Forms

For large forms, you can divide the content into multiple logical pages (creating a "Wizard" style user interface). This involves wrapping controls in Page containers and using specific JavaScript methods to handle navigation.

See Also

Videos and Components

Introduction to JSON Forms

JSON Forms - Q &A Feb 19 2025

JSONForm Control - The Future Of Data Collection 2023 June 21

The Preview Window

In this video we show how you can use the Preview window in the JSON Form designer to get a real-time preview of your JSON Form as you design it.

.GetValue() and .setValue()

In this video we show how the standard UX component .getValue() and .setValue() method work with a JSON Form. We also show how JSON Form data are submitted to the server when the UX is submitted.

.GetValue() and .setValue() on Individual JSON Form fields

In this video we show how the .getValue() and .setValue() methods can operate on individual controls in the JSON Form.

Download Component

How to create tab and accordion controls

In this video we show how to create Tab and Accordion controls in a JSON Form.

Download Component

How to dynamically set the structure of a JSON Form

In this video we show how you can dynamically set the structure of a JSON form using a Javascript function.

Download Component

Data Bound UX Component Using JSON Forms

In this video we show how you can create a Data Bound UX component using JSON Forms to edit data in a SQL table.

Saving JSON Form definitions in the Repository

In this video we show how you can save JSON Forms in a 'repository' (a SQL database) and then dynamically load forms from the repository at run-time.

Using the JSON Form Tester

The JSON Form tester allows advanced users to experiment with different JSON definitions. In this video we show how the JSON Form Tester can be used.

Defining Display Formats for Fields

In this video we show how you can define display formats for fields in a JSON Form. For example, you might want to display a field with a leading $ sign, but when the field has focus so that you can edit the value in the field, you might want to display the raw (unformatted) value in the field.

Dynamic Filters on Dropdown, Combo and Edit-combo Controls

A common requirement for controls with picklists (e.g. dropdown, or combo controls), is to dynamically filter the choices in the picklist. For example, if your form has a picklist for Country and one for City, you typically only want the choices in the City picklist to show cities in the selected Country.

Custom Integer-Step Control

In this video we show how you can turn a standard textbox control into a custom Integer-Step control.

Download Component

Video Transcript: JSON Forms - Q&A Feb 19 2025

[0:03] Hello and welcome to the Alpha Software demo and Q&A webcast. I’m Dave McCormack, VP of Product Management at Alpha Software. Today we’re going to be talking about JSON Forms, and we’re also here to take your questions. You can type questions into the Questions box or Chat box in the GoToWebinar control panel, or send them to guides@alphasoftware.com .

[0:39] So—JSON Forms. What are they, and why should we use them? JSON Forms are a feature that came out about a year and a half ago, but we haven’t talked about them very much. I think we mentioned them at a DevCon. It was inspired by Alpha TransForm as a quick way to generate forms, and it’s also used in Alpha TransForm now—for example as the newer interface for the Home Control we demonstrated about a month ago.

[1:17] Before I go any further, I always ask at the beginning of every webinar: can you hear me, and can you see my mouse moving around on the screen? If the answer is yes, type that into the Questions box. (Thanks—sounds like we’re good.)

[1:38] Let’s look at two UX components. Both are forms and both have around 200 fields—about 203 fields—related to apartment inspection. One is built the regular way, by laying out text fields directly onto the UX. The one on the right is a JSON Form. You’ll notice the structure is different: you don’t see the fields laid out on the UX. Instead, the fields are defined inside what’s called a JSON Form.

[2:27] Why would you want to do that? First, it can be easier to manage large components. It’s also a little faster to save, especially as your components get large. It’s also slightly—emphasis on slightly—more lightweight when delivering the application to the client device. In this example, the regular form took about 3.2 seconds to load, and the JSON Form took about 2.7 seconds—roughly half a second less. Percentage-wise that can be significant, and it matters if you have a lot of people hitting your server or your forms get even larger than 200 fields.

[3:20] There are other lightweight approaches—like using a ViewBox control with a List and editor sets—and we’ll cover that in an upcoming webinar. Today we’re just focusing on JSON Forms. Besides being lighter weight, JSON Forms can do a really cool “magic trick”: they can be used to create data-driven forms.

[3:44] A data-driven form is dynamically generated from a list of questions. Those questions—and field types and other settings—can come from a spreadsheet or a database. They could also be generated programmatically using JavaScript or Xbasic to create the form definition on the fly while the user is using it.

[4:15] One big benefit of the spreadsheet/database method is that it’s surprisingly common for businesses—especially manufacturing companies doing quality tests—to already track lists of questions or tests in a spreadsheet or database. With JSON Forms, the database can generate the form. So if you want to make changes to the form, you change the database or spreadsheet, which is much easier for someone with less technical skills than the developers on this call. You can even give a client a spreadsheet and say: change the spreadsheet, and it will change the form.

[5:21] So JSON Forms can also be changed dynamically and programmatically. There’s a lot they can do, and I’m sorry we haven’t really dug into it until now, but we’ll try to make up for lost time.

[5:35] Today I want to cover where to find documentation (there isn’t a lot of written documentation, but there are many good videos), setting values using JavaScript, dynamically creating forms (including importing from a spreadsheet), the JSON Forms Genie, styling and containers (tabs/accordion/pages/freeform), special controls, and handling hierarchical data using repeating sections (parent/child/grandchild relationships).

[6:44] First: documentation. Let me paste a link into the chat. You can also Google “JSON Forms” and find it. But right now it’s not documented as written documentation inside our documentation system—you’ll find it in release notes and on the page I’m linking to. What we do have is a lot of videos, and they’re really good.

[7:23] Now let’s look at the two forms from earlier. Here’s the standard one with all fields directly on the UX. Here’s the one where the fields are wrapped inside the JSON Form. I can double-click to open the JSON Form properties and you’ll see the fields are listed there with names and labels.

[8:14] Let’s build a new JSON Form from scratch. I’ll create a new blank UX component, add a control, and choose a JSON Form control. Now I can double-click it to set its properties. I’ll save it and call it “JSON Form Webinar.”

[9:11] It starts blank. To add fields, I add items. I click “Add Item,” choose a textbox, and click OK. Like adding controls on a UX, I can add a single control or create multiple controls at once. For a single control, I give it a label like “First Name” and a variable name like “first name,” and that’s it.

[9:49] Or I can do “Create multiple” and paste a comma-delimited list. Yesterday I actually had ChatGPT come up with a list for me. You can paste a bunch of names and it will create all the fields.

[10:23] I’ll add a couple more fields quickly—“Last Name” and “City.” Now I have three fields. If I click Preview, you see “First Name,” “Last Name,” and “City.”

[10:51] There’s something cool in the preview: if you have a lot of controls, you can click on a particular control in preview and it jumps right to that control in the list. No big deal with three fields, but extremely useful with 200.

[11:24] Now I’ll save again. This might remind you of a ViewBox where you’re adding items, but here we actually have fields, which means they can be edited and submitted to a database or data source. I can add standard Submit and Reset buttons to the UX.

[12:05] Here’s a really useful trick: instead of always writing an Ajax callback event manually, you can use server-side “After Dialog Validate” (right before things are saved) and put debug code there. That way, when you run it, you can inspect what was sent to the server.

[12:46] In Working Preview, I enter “Bob” and “Smith,” then submit. The debugger opens. If I inspect the event variable (e), I can look at the submitted data. What comes back is a JSON object: first name Bob, last name Smith, city blank. That’s how the data comes back to the server.

[13:27] You’ll get that as an object and you can parse it using something like JSON parsing, then use it server-side in Xbasic.

[14:05] So that shows how you can use standard Submit/Reset buttons with a JSON Form and receive the submitted JSON package server-side.

[14:29] Next I want to look at importing from a spreadsheet and dynamic generation. I’m going to scrub through a video and show you the highlights.

[15:58] In this example, an Ajax callback is used, and there are helper functions involved. One is A5Helper_getJSONFormItems_fromDatabase(), a high-level helper written for taking data from a database (SQL or anything with a connection string—also Excel spreadsheets) and generating JSON Form items. Then there’s a method like setJSONFormItems() to apply them.

[17:08] You can download the sample component so you can copy and paste the code. Look under the Data Driven JSON Forms resources to see how that works.

[17:17] Now: containers and styling. JSON Forms support containers like the regular UX. You can use groups, repeating containers (for parent/child data), pages (multiple pages of fields with navigation), freeform layout, and tabs. There are also predefined controls, like buttons that go directly to a page/container.

[19:06] There are list and detail view buttons because it’s common to use a JSON Form as the detail view for a List control. I’ll show that when we get to the Quick Start Genie, which I’ll cover near the end.

[19:30] A question everyone has at first: if all my controls are inside the JSON Form, how do I programmatically set a value? With regular controls, you can add a button that sets a field value using Action JavaScript.

[20:22] For a normal field, you might choose an Action JavaScript like “Set Value,” pick the target control, and set “Hello World.” Then when you click the button, the textbox gets that value.

[21:30] But how do you do that with a JSON Form? The JSON Form appears as one control name on the UX. How do you target a field inside it? We’ve provided two ways to set values.

[21:54] First, you can use standard getValue/setValue. But keep in mind: you’re working with JSON. If you do getValue on the JSON Form, you get all field values back as a JSON payload—like the debug object we saw. If you setValue, you’re typically setting values as a full object.

[22:33] Second, if you want to get or set a particular field inside the JSON Form, there’s a specific syntax that targets the field within the JSON Form (a “JSONForm::FormName::FieldName” style addressing pattern). That lets you pull out or set a single field such as “City.”

[23:26] Next I want to tour the videos and highlight some topics. There are videos on repeating sections and hierarchical data, calculations like totals and averages, containers like tabs and accordion, pages, responsiveness, data-driven forms, list detail view layouts, databound UX usage, the JSON Form tester tool, and display formats.

[26:05] The JSON Form Template Tester Window is a separate tool under Tools. It lets you paste JSON data, templates, JavaScript, and CSS and see how it behaves. It’s handy for writing and debugging, and it can be used for more than just JSON Forms.

[27:04] Control types: JSON Forms support many controls—data controls like multi-select lists, auto-suggest, checkboxes, dropdowns, star rating, bound images, basic controls like button/HTML/image/custom JSON, and containers like tabs, accordions, and repeating sections.

[28:11] Now the Quick Start Genie. When you insert a JSON Form and open its properties, there’s a Quick Start Genie link. It can create a form from sample JSON data, offer “quick input” syntax to define fields and types, build a form based on list data, and support UX data binding via field mapping. There are also options related to older Xdialog patterns.

[30:14] When the JSON Form Builder is done, it creates the JSON form items definition (which is JSON). Under “More,” you can import/export and save JSON Forms to a repository so you can reuse them across multiple components.

[31:05] One place we’ve used JSON Forms heavily is in the new Alpha TransForm UI. The dropdowns, accordions, and other configuration screens are JSON Form-driven. That’s great because we can edit the definitions the UI pulls from, rather than editing the application code itself. It’s convenient for teams: one person can publish the component, while others update the definition content and layout.

[32:40] Now I’ll check questions. One question: can JSON Forms be populated like a ViewBox? Yes. A ViewBox is similar in some ways, but a JSON Form is designed specifically as a form device, not just for viewing data.

[33:29] Another question mentions issues using containers and frames in a JSON Form—unexpected behavior. If you’re running into that, email guides@alphasoftware.com with details. We can diagnose it, and I’d be happy to show it in a future webcast.

[34:05] Another question: what’s the use case for JSON Forms versus standard controls? The biggest use case is flexibility: data-driven forms you can rearrange on the fly, generate dynamically, or let a client edit through a spreadsheet. There can also be a performance advantage with very large forms, though it depends. For example, in our Alpha test drive app, there was a JSON Form in the login screen originally, but I removed it and went back to standard controls because it’s easier for someone else to edit, and a login form doesn’t need to be data-driven.

[35:35] Someone asks what version I’m using. I’m using the latest release from Tuesday. If you think you’ve found a bug or unexpected behavior, email guides@alphasoftware.com or bugs@alphasoftware.com . Include an example and specify what version you’re using.

[36:08] Another question: how did I get the load time numbers at the bottom of the form? I relied on Chrome. In Working Preview, there’s a link to open Chrome debugger. In DevTools, go to Network and reload (Ctrl+R). It will show the load time (for example, 2.11 seconds). That’s a handy way to measure performance and optimize.

[37:35] That looks like it. If I didn’t get to your question or didn’t answer it the way you wanted, email guides@alphasoftware.com . Thanks everyone for showing up. I hope to see you at our next Wednesday webcast. Until then, take care and stay well. Bye-bye.

See Also