Skip to main content

How to Generate Continuous Numbers Across Two Forms

Business Scenario

This solution applies when two forms need to share the same numbering sequence, such as in inventory management.

For example, there may be two stock-in forms: one used by sales representatives and another used for general stock-in records. When data is submitted through either form, both forms must use the same numbering sequence.


Expected Result

The final numbering sequence is as follows:

  • Form 1: 1, 2, 3...

  • Form 2: 4, 5...

  • Form 3: 6, 7...


Design Approach

Use the MAPX function to generate sequence numbers for both forms, together with a Refresh button and an Aggregate Table.

The Refresh button is also required for concurrency control to prevent duplicate numbers when multiple records are submitted at the same time.


Form Configuration

Form 1 and Form 2 use similar configurations, with slight differences in their formulas.

Form 1

Serial Number: Add a formula to the Serial Number field. In the field properties, also enable validation to prevent duplicate values.

IF(ISEMPTY(Radio)==0,MAX(VALUE(MAPX('last',Form 1 Helper Field 1,Form 1 Helper Field 1,Form 1 Serial Number))+1, VALUE(MAPX('last',Form 1 Helper Field 1,Form 2 Helper Field 1,Form 2 Serial Number))+1),MAX(VALUE(MAPX('last',Form 1 Helper Field 1,Form 1 Helper Field 1,Form 1 Serial Number))+1,VALUE(MAPX('last',Form 1 Helper Field 1,Form 2 Helper Field 1,Form 2 Serial Number))+1))

Radio: Add a radio and name it Refresh.

Helper Field 1: Add a Single Line field and set its default value to 1.

Helper Field 2: Add a Number field and set its default value to 1.

Form 2

Serial Number:Add a formula to the Serial Number field. In the field properties, also enable validation to prevent duplicate values.

IF(ISEMPTY(Radio)==0,MAX( VALUE(MAPX('last',Form 2 Helper Field 1,Form 2 Helper Field 1,Form 2 Serial Number))+1, VALUE(MAPX('last',Form 2 Helper Field 1,Form 1 Helper Field 1,Form 1 Serial Number))+1),MAX(VALUE(MAPX('last',Form 2 Helper Field 1,Form 1 Helper Field 1,Form 1 Serial Number))+1,VALUE(MAPX('last',Form 2 Helper Field 1,Form 2 Helper Field 1,Form 2 Serial Number))+1))

Radio : Add a radio and name it Refresh.

Helper Field 1: Add a Single Line field and set its default value to 1.

Helper Field 2: Add a Number field and set its default value to 1.

Aggregate Table

Use an Aggregate Table to ensure that duplicate numbers cannot exist across the two forms.

Add a Number field to each form and set its default value to 1. Then configure the following formula:

Helper Field 2 + Helper Field 2

Set the aggregate validation condition to:

Formula <= 1

Result

As shown below, the numbers generated in Form 1 and Form 2 together form one continuous numbering sequence.

Did this answer your question?