# Setting postman env var via Postman App - number stored as string

**URL:** <https://community.postman.com/t/setting-postman-env-var-via-postman-app-number-stored-as-string/22051>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [March 29, 2021, 9:12pm UTC](https://community.postman.com/t/setting-postman-env-var-via-postman-app-number-stored-as-string/22051 "2021-03-29T21:12:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cekeren](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@cekeren](https://community.postman.com/u/cekeren)\
**Post date:** [March 29, 2021, 9:12pm UTC](https://community.postman.com/t/setting-postman-env-var-via-postman-app-number-stored-as-string/22051/1 "2021-03-29T21:12:42Z")

</div>

When I’m setting an environment variable via the Postman App, it’s setting my numerical value as a string.

**As a result this test fails:**  
`pm.expect(item.output_id).to.be.oneOf([pm.environment.get("id"),pm.environment.get("id_2")]);`  
**With this error:**  
`AssertionError: expected 759390 to be one of ['759390', 824128] `

Notice that the first “oneOf” is wrapped in a string? That var was set via Postman App, where as the 2nd var was set using a response body from a prior call, using `pm.environment.set()`

I’m not really sure I see a way to override this and set a number (id) as a number type in the UI/App. Help would be appreciated, thank you in advance!

---

<div class="post-metadata">

**Author:** ![taehoshino](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/taehoshino/32/6608_2.png) [@taehoshino](https://community.postman.com/u/taehoshino)\
**Post date:** [March 30, 2021, 12:28am UTC](https://community.postman.com/t/setting-postman-env-var-via-postman-app-number-stored-as-string/22051/2 "2021-03-30T00:28:10Z")

</div>

Hey @cekeren 👋 Welcome to the Postman Community 🎉

If you want to convert a string to a number, you can do:

```
const numId = Number(pm.environment.get('id'))
pm.environment.set('id', numId)

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![cekeren](https://avatars.discourse-cdn.com/v4/letter/c/c77e96/32.png) [@cekeren](https://community.postman.com/u/cekeren)\
**Post date:** [March 30, 2021, 1:27am UTC](https://community.postman.com/t/setting-postman-env-var-via-postman-app-number-stored-as-string/22051/3 "2021-03-30T01:27:20Z")

</div>

Hey there, thank you! Yes - this helps. I had half-thought “I could convert the var before testing” but I was hoping there was a better way of setting it at the UI/App level. This still gets me to where I need to be though, thank you!

Cheers.

PS - thank you so much for the quick response, let alone the response! The community is just another reason why I convert all of my peers/colleagues to Postman for API anything!
