# Pre-request scripts are not executed

**URL:** <https://community.postman.com/t/pre-request-scripts-are-not-executed/71480>\
**Category:** Help Hub\
**Tags:** tests, variables, collections\
**Created:** [November 20, 2024, 5:51pm UTC](https://community.postman.com/t/pre-request-scripts-are-not-executed/71480 "2024-11-20T17:51:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flight-candidate-531](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@flight-candidate-531](https://community.postman.com/u/flight-candidate-531)\
**Post date:** [November 20, 2024, 5:51pm UTC](https://community.postman.com/t/pre-request-scripts-are-not-executed/71480/1 "2024-11-20T17:51:06Z")

</div>

Hello community.

I did a pre-request script that checks the value of an environment variable and increments the value +1 at each iteration and update the value. Everything worked just fine up until some point (after a merge between collections), now it does not check with the environment variables to read the value and does not increment it as well. At every iteration it logs a value smaller than the value that is in the environment variables.

```auto
let currentValue = pm.environment.get("env_var");

let incrementedValue = (parseInt(currentValue, 10) + 0).toString().padStart(10, '0');

pm.environment.set("value", incrementedValue);

console.log("value:", incrementedValue);

```

I did the usual IT guys fixes(quit postman, restart machine, etc), but nothing worked.

Similar scripts are used for other variables, but only this script is not working. Do you have any Ideea why?

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [November 20, 2024, 7:23pm UTC](https://community.postman.com/t/pre-request-scripts-are-not-executed/71480/2 "2024-11-20T19:23:22Z")

</div>

> [@flight-candidate-531](#):
>
> `padStart`

Hi @flight-candidate-531. Welcome to the Postman Community :postman_logo:.

Shouldn’t the line `parseInt(currentValue, 10) + 0` be `parseInt(currentValue, 10) + 1` since you want this to increment the value by 1 on every iteration?

Also, why are you using padStart() here?

---

<div class="post-metadata">

**Author:** ![flight-candidate-531](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@flight-candidate-531](https://community.postman.com/u/flight-candidate-531)\
**Post date:** [November 21, 2024, 9:46am UTC](https://community.postman.com/t/pre-request-scripts-are-not-executed/71480/3 "2024-11-21T09:46:15Z")

</div>

Thanks for the help, works fine now after update.  
I used padStart strictly for the visibility of the value length and to set an incrementation limit. Output looks like this: 0000012345, 0000012346… and so on.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [November 24, 2024, 9:46am UTC](https://community.postman.com/t/pre-request-scripts-are-not-executed/71480/4 "2024-11-24T09:46:34Z")

</div>

Closed on November 24, 2024, 9:46am UTC

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