How to create auto coded variable | Experience Community
Skip to main content
Question

How to create auto coded variable

  • July 8, 2026
  • 3 replies
  • 40 views

I have two question, Q1 and Q2.

If Q1, it is asking for state and Q2 for region.

If Q1 selects any states under the region stated in Q2, the region in Q2 should be automatically check or selected.

3 replies

hokie404
Level 2 ●●
Forum|alt.badge.img+4
  • Level 2 ●●
  • July 8, 2026

Can you use embedded data to automatically code a region for each respondent and have them skip Q2 altogether?


Forum|alt.badge.img+28

Using display logic:

You can set up Q2’s region choices to be displayed based on the states selected.

Then, add default choice for Q2 for all choices.

 

Using branch logic (alternative but similar process as mentioned by hokie404 above):

After Q1, in the survey flow, add a branch logic to check if Q1’s selection falls under a region, then add embedded data of region. Add more branch logic depending on the number of regions, skipping Q2 altogether.


arunxmarchitect
Level 4 ●●●●
Forum|alt.badge.img+8

@LKC , For most scenarios, I would recommend Option 2 as it is a no-code solution and is easier to maintain. However, if respondents need to see the region automatically selected before submitting the survey, then Option 1 is the better choice.

Option 1: JavaScript (Real-time selection)

Use JavaScript on Q2 to automatically select the appropriate region based on the state selected in Q1 when the page loads or when Q1 changes. This is ideal when the auto-selection needs to be visible to the respondent for review or editing.

Option 2: Survey Flow + Embedded Data (No JavaScript)

Use Embedded Data to store the selected state's AutoCode (or another mapping value). In the Survey Flow, use branch logic to determine which region the selected state belongs to, then set an Embedded Data field (e.g., CustomRegion_AutoCode) to the corresponding region value. Finally, use that Embedded Data field to prepopulate the default choice for Q2.

Important: Place this Embedded Data/branch logic after the dependent question (Q2) block in the survey flow so the selected value is available before the mapping is performed.

The screenshot below shows an example of using Survey Flow and Embedded Data to map a selected state to its corresponding region without requiring JavaScript.