# Reading global environment variable from function node

**URL:** <https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619>\
**Category:** General\
**Tags:** function-node\
**Created:** [27 September 2023 18:22 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619 "2023-09-27T18:22:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![msbadreldin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/msbadreldin/32/83265_2.png) [@msbadreldin](https://discourse.nodered.org/u/msbadreldin)\
**Post date:** [27 September 2023 18:22 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/1 "2023-09-27T18:22:08Z")

</div>

Hi there,

I have set "global environment variable" in user setting with value of type "credential", when i try to resolve the value in function node using env.get('xxx'), the value shows like " **PWRD**" using node.error.

What do i miss over here?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [27 September 2023 19:57 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/2 "2023-09-27T19:57:02Z")

</div>

Works here:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c38d8561f9421237f10d6d32789398798bd4a808.png)

 ![SCR-20230927-szca](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f5e9bcfc9c4a82dff961da63e4e4a3c9c5a1e955.png)

---

<div class="post-metadata">

**Author:** ![msbadreldin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/msbadreldin/32/83265_2.png) [@msbadreldin](https://discourse.nodered.org/u/msbadreldin)\
**Post date:** [27 September 2023 19:58 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/3 "2023-09-27T19:58:31Z")

</div>

I mean "credential" type not string, you may change the type and try once more please

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [27 September 2023 20:41 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/4 "2023-09-27T20:41:43Z")

</div>

Hi @msbadreldin !  
Welcome to this forum!

> [@msbadreldin](#):
>
> the value shows like " **PWRD**"

The value you get - when trying to read back the credential type - is ` __PWRD__ `.  
This is a mechanism implemented to keep the credential secret - in the editor.  
There's a [chapter in the documentation](https://nodered.org/docs/creating-nodes/credentials) covering the details of credential management; it's yet lacking valuable information how to handle your use case.

---

<div class="post-metadata">

**Author:** ![msbadreldin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/msbadreldin/32/83265_2.png) [@msbadreldin](https://discourse.nodered.org/u/msbadreldin)\
**Post date:** [27 September 2023 21:26 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/5 "2023-09-27T21:26:41Z")

</div>

Thanks @ralphwetzel !  
I think this is a new feature released in 3.1 version but i couldn't find enough information of how to use it

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [28 September 2023 06:19 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/6 "2023-09-28T06:19:35Z")

</div>

I had some time to dig around in the code base: Looks like you fell over an issue in the global env management for `credential` types. This needs to be fixed; as it is currently, you won't get the credentials value back.

I propose you raise an issue in the NR GitHub repo!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 November 2023 06:20 UTC](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/7 "2023-11-27T06:20:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
