# Setting a global variable in a pre-request script isn't working

**URL:** <https://community.postman.com/t/setting-a-global-variable-in-a-pre-request-script-isnt-working/16548>\
**Category:** Help Hub\
**Created:** [October 7, 2020, 3:00pm UTC](https://community.postman.com/t/setting-a-global-variable-in-a-pre-request-script-isnt-working/16548 "2020-10-07T15:00:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![darrell.tunnell](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@darrell.tunnell](https://community.postman.com/u/darrell.tunnell)\
**Post date:** [October 7, 2020, 3:00pm UTC](https://community.postman.com/t/setting-a-global-variable-in-a-pre-request-script-isnt-working/16548/1 "2020-10-07T15:00:57Z")

</div>

I have a pre-request script on my collection, that sets a global variable value:

```auto
pm.globals.set("SOME-HEADER", headerVal);
console.log(headerVal)

```

I have a single request in this collection, and when I execute it, I can see the console log is outputting the correct value I expect.

However, the request has a header, and I am attempting to set this from the the global variable {{SOME-HEADER}} - however I can see that this is always set to the current value of the variable as shown in the variables UI. My pre-request script on the collection is seemingly setting it to a new value, but then then new value is not used on the request. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![michal.robaszewski.j](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michal.robaszewski.j/32/5378_2.png) [@michal.robaszewski.j](https://community.postman.com/u/michal.robaszewski.j)\
**Post date:** [October 7, 2020, 3:23pm UTC](https://community.postman.com/t/setting-a-global-variable-in-a-pre-request-script-isnt-working/16548/2 "2020-10-07T15:23:21Z")

</div>

Hi,  
Can you send a picture of pre-req. tab?  
I have tried setting Header in pre req as a global var and then it was used in Headers with this value given in pre-req.

> **pre-req**
>
> ```auto
> pm.globals.set("SOME-HEADER", "headerVal");
> 
> ```

 ![example_header](https://us1.discourse-cdn.com/getpostman/original/3X/4/9/4954fa5c3e63e007a8f312213466728d6a0cac08.png)

If you set up pre-req in Collection, Directory, Request places be sure that nothing along not save different value.

For me this is expected behavior.
