# Select initial value not working with query parameter in production (works in preview)

**URL:** <https://community.weweb.io/t/select-initial-value-not-working-with-query-parameter-in-production-works-in-preview/20740>\
**Category:** Ask us anything\
**Created:** [February 3, 2026, 1:25pm UTC](https://community.weweb.io/t/select-initial-value-not-working-with-query-parameter-in-production-works-in-preview/20740 "2026-02-03T13:25:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DiogoDias](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@DiogoDias](https://community.weweb.io/u/DiogoDias)\
**Post date:** [February 3, 2026, 1:25pm UTC](https://community.weweb.io/t/select-initial-value-not-working-with-query-parameter-in-production-works-in-preview/20740/1 "2026-02-03T13:25:19Z")

</div>

I have a select component that should initialize its value based on a URL query parameter. It works correctly in preview mode but fails in production — always showing the default value instead of the query parameter value.

**Setup:**

1. **Query variable** `country` (Type: Query, Default: “US”, Save in local storage: Yes)

2. **Static variable** with countries array:

```auto
[
  { "name": "Afghanistan", "alpha-2": "AF", "phoneCode": "93", ... },
  { "name": "France", "alpha-2": "FR", "phoneCode": "33", ... },
  ...
]

```

1. Select options formula:

```auto
return variables['a9bd69fa-0035-4a70-82ce-b8a54cdeaac5'].map(country => ({
  label: country.name,
  value: country['alpha-2'],
  icon: country['alpha-2'].toLowerCase(),
  phoneCountryCode: wwFormulas.concatenate("+", country['phoneCode']) 
}));

```

1. **Value per item:** `context.mapping?.['phoneCountryCode']` (returns “+33” for France)
2. **Initial value (single) formula:**

````auto
const countries = variables['a9bd69fa-0035-4a70-82ce-b8a54cdeaac5'];
const countryCode = variables['country'];
const found = countries.find(c => c['alpha-2'] === countryCode);
return found ? wwFormulas.concatenate("+", found['phoneCode']) : "+1"
```

**Behavior:**

- **Preview:** Navigate to `?country=FR` → Select correctly shows France (+33) ✅
- **Production:** Navigate to `?country=FR` → Select shows US (+1) ❌

**Debug console shows:**
```
Setting value for country
"FR"
Updating localStorage to synchronize with country

````

So the query parameter IS being read correctly, but the select doesn’t reflect it.

**What I’ve tried:**

- “Preserve on navigation” → No effect

- “On mounted” workflow to set the value → No effect

- Adding delays (100ms, 1 second) before setting value → No effect

- Checking local storage (variable not stored there despite setting)

- Tested with single query param only → Same issue

Is there a known timing issue with query variables and select initial values in production? How can I ensure the select initializes with the correct value from the query parameter without adding loading states or delays?

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [February 3, 2026, 1:46pm UTC](https://community.weweb.io/t/select-initial-value-not-working-with-query-parameter-in-production-works-in-preview/20740/2 "2026-02-03T13:46:02Z")

</div>

Hi @DiogoDias 👋

Not sure why it would be working inside the editor but not in production.

I tried a different approach on my side which seems to work: [https://www.tella.tv/video/select-with-query-72oc](https://www.tella.tv/video/select-with-query-72oc)

Can you take a look and let me know if that works for you?
