# Reset variable like the button

**URL:** <https://community.postman.com/t/reset-variable-like-the-button/40845>\
**Category:** Help Hub\
**Created:** [November 7, 2022, 2:57pm UTC](https://community.postman.com/t/reset-variable-like-the-button/40845 "2022-11-07T14:57:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [November 8, 2022, 1:38pm UTC](https://community.postman.com/t/reset-variable-like-the-button/40845/2 "2022-11-08T13:38:35Z")

</div>

Hi @ykisaragi1

Have a look at these two links;

> [@How to reset variables to initial value from script](https://community.postman.com/t/how-to-reset-variables-to-initial-value-from-script/20629):
>
> Add this to first request’s pre-request script: pm.environment.set("resetValue",pm.collectionVariables.toJSON().values) This wiil store all initial value to resetValue variable And in the last request’s test script use pm.environment.get("resetValue").forEach((a)=\>pm.collectionVariables.set(a.key,a.value)) Now we are resetting all collectionVariables to the initially saved value

[https://www.postman.com/praveendvd-public/workspace/postman-tricks-and-tips/collection/8296678-c053b94a-fd95-4acd-aa67-81bc6d80528b](https://www.postman.com/praveendvd-public/workspace/postman-tricks-and-tips/collection/8296678-c053b94a-fd95-4acd-aa67-81bc6d80528b)

---

_[View the full topic](https://community.postman.com/t/reset-variable-like-the-button/40845)._
