# Increasing number field by 1 with Custom Code

**URL:** <https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474>\
**Category:** Data Hub\
**Created:** [February 5, 2024, 4:51pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474 "2024-02-05T16:51:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ABrandt](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@ABrandt](https://community.hubspot.com/u/ABrandt)\
**Post date:** [February 5, 2024, 4:51pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474/1 "2024-02-05T16:51:15Z")

</div>

Hello Community,

I’m making a workaround in order to be able to count the number marketing emails delivered but after a certain condition/date.

Since the native HubSpot field **Number of marketing emails delivered** is a number field that can’t be adjusted based on other criteria, I’m making a Workflow that adds +1 to a new custom property, every time the Number of marketing emails delivered change (as well as and other criteria are met)

Since the Workflow is updating a custom number field, what code could I have that will take the existing value and add 1 ?

Example, its is 10 in the field, the workflow runs and update the custom field to 11.  
Thank you

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [February 5, 2024, 9:53pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474/2 "2024-02-05T21:53:18Z")

</div>

Hey @ABrandt, Happy Monday!

You can achieve this by using HubSpot’s custom code within your workflow. The code will fetch the current value of the custom field, add 1 to it, and then set the updated value back to the custom field.

I want to invite our top experts to share their thoughts **@ArdenM,** **[@Jonas\_De\_Mets](https://community.hubspot.com/t5/user/viewprofilepage/user-id/654259),** and **@JTBuys** any recommendations for **@ABrandt** matter?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![JTBuys](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jtbuys/32/62318_2.png) [@JTBuys](https://community.hubspot.com/u/JTBuys)\
**Post date:** [February 5, 2024, 10:20pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474/3 "2024-02-05T22:20:01Z")

</div>

Hey @ABrandt,

Would a workflow like below support your needs?

This workflow will enroll contacts every time the Marketing emails delivered property updates and they meet the filter requirements (e.g. contact is a member of a list). Then an action increases the Custom Marketing Emails Delivered property by one.

If this would not work, is there criteria than cannot be checked through enrollment filters or active list filters?

 ![Screenshot 2024-02-05 at 5.12.13 PM.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/e/8ebab4b32cddcfae1ce4496a3337dcd0319053bf.png)

---

<div class="post-metadata">

**Author:** ![ABrandt](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@ABrandt](https://community.hubspot.com/u/ABrandt)\
**Post date:** [February 6, 2024, 4:00pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474/4 "2024-02-06T16:00:48Z")

</div>

Hello @JTBuys

Thanks for the suggestions. I did not realize there was an “ **Increase of decrease value** ” action.

Also, the way you have setup your triggers look much better than what I did. Thanks for the suggestions.

---

<div class="post-metadata">

**Author:** ![ArdenM](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@ArdenM](https://community.hubspot.com/u/ArdenM)\
**Post date:** [February 8, 2024, 6:33pm UTC](https://community.hubspot.com/t/increasing-number-field-by-1-with-custom-code/99474/5 "2024-02-08T18:33:39Z")

</div>

Thanks for the tag @PamCotton! Fully agree with @JTBuys solution here, just wanted to add that even if you think you can do something in HubSpot Workflows with custom code, it’s always better to look for a native solution using the workflow actions first. Custom code isn’t highly supported, may break invisibly due to updates, and is harder for anyone that isn’t you to maintain.

Glad the right solution was able to be surfaced here!
