# Store Variables for Future Iterations?

**URL:** <https://community.hubspot.com/t/store-variables-for-future-iterations/71396>\
**Category:** Data Hub\
**Created:** [December 16, 2022, 3:25pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396 "2022-12-16T15:25:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew\_moreno](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@andrew\_moreno](https://community.hubspot.com/u/andrew_moreno)\
**Post date:** [December 16, 2022, 3:25pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/1 "2022-12-16T15:25:09Z")

</div>

Hi,

I’m pretty new to using HubSpot’s Custom Code action in workflows, but I was wondering if it was possible to store data inside of a variable for future iterations of a workflow?

We are creating a workflow to compare zip codes of a contact to zip codes radius from a location we input. We are using an API to retrieve this information from a database and are limited in the amount of calls we can make an hour.

Currently, the only way I can think to do this is making an API call for each contact that becomes enrolled in the workflow, but we would hit out call limit pretty fast. If I could store the information I get from the API call to be used in the future, it would keep Us within the call limit threshold.

Any help is appreciated! Thank you!

Andrew

---

<div class="post-metadata">

**Author:** ![kvlschaefer](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kvlschaefer/32/71076_2.png) [@kvlschaefer](https://community.hubspot.com/u/kvlschaefer)\
**Post date:** [December 19, 2022, 2:54pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/2 "2022-12-19T14:54:47Z")

</div>

Hi [@andrew\_moreno](https://community.hubspot.com/t5/user/viewprofilepage/user-id/492513),

Thank you for reaching out!

I wanted to tag in our community members to see if they have insight.

Hi @CMcKay, @Hollyce, @PNispel - Do you have experience with storing variables in HubSpot?

Thank you!

Best,

Kristen

---

<div class="post-metadata">

**Author:** ![Hollyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hollyce/32/2764_2.png) [@Hollyce](https://community.hubspot.com/u/Hollyce)\
**Post date:** [December 20, 2022, 2:58pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/3 "2022-12-20T14:58:22Z")

</div>

I do not have experience storing variables, but I am definitely interested in learning this technique if it’s possible. I could use it in a workflow I’m troubleshooting now.

---

<div class="post-metadata">

**Author:** ![CMcKay](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cmckay/32/80666_2.png) [@CMcKay](https://community.hubspot.com/u/CMcKay)\
**Post date:** [December 19, 2022, 3:54pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/4 "2022-12-19T15:54:46Z")

</div>

You used to be able to do this by just storing the variable outside of the context.main function but I’ve notice that sometimes it restarts if you haven’t trigger the function in a little bit. How far apart are the enrollments? I’ve also had some success with reading and writing out to my database on every run. [@andrew\_moreno](https://community.hubspot.com/t5/user/viewprofilepage/user-id/492513) just let me know, also I can hop on a call later today and walk you through it if you want.

---

<div class="post-metadata">

**Author:** ![andrew\_moreno](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@andrew\_moreno](https://community.hubspot.com/u/andrew_moreno)\
**Post date:** [December 19, 2022, 5:55pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/5 "2022-12-19T17:55:06Z")

</div>

Hi,

I would say once turned on, the enrollments should be triggering at the very least once a minute. It is triggered by new customers or a change in a contact’s postal code. If you have time for a call that would be great just to make sure I am doing this correctly. I am available from 3 - 4 CST.

---

<div class="post-metadata">

**Author:** ![CMcKay](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cmckay/32/80666_2.png) [@CMcKay](https://community.hubspot.com/u/CMcKay)\
**Post date:** [December 20, 2022, 6:26pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/6 "2022-12-20T18:26:56Z")

</div>

Here’s my calendar, you can book time whenever you want: [hubspot.com/meetings/carter-mckay](http://hubspot.com/meetings/carter-mckay)

---

<div class="post-metadata">

**Author:** ![CMcKay](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cmckay/32/80666_2.png) [@CMcKay](https://community.hubspot.com/u/CMcKay)\
**Post date:** [December 28, 2022, 2:26pm UTC](https://community.hubspot.com/t/store-variables-for-future-iterations/71396/7 "2022-12-28T14:26:44Z")

</div>

@Hollyce [@andrew\_moreno](https://community.hubspot.com/t5/user/viewprofilepage/user-id/492513) Funny enough I just found the section I was looking for in the docs:

 ![CMcKay_0-1672237576049.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/5/5c29851b0bf84f9761208995e3eed39ae2ebab8a.png)

> **[Workflows | Custom Code Actions - HubSpot docs](https://developers.hubspot.com/docs/api-reference/legacy/automation/workflow-actions/custom-code-actions)**
>
> Instructions for using custom code actions in workflows
