⚙ Operations Hub

ABrandt
Member

Increasing number field by 1 with Custom Code

SOLVE

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

0 Upvotes
2 Accepted solutions
JTBuys
Solution
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Increasing number field by 1 with Custom Code

SOLVE

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

View solution in original post

ArdenM
Solution
Top Contributor

Increasing number field by 1 with Custom Code

SOLVE

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!

View solution in original post

0 Upvotes
4 Replies 4
ArdenM
Solution
Top Contributor

Increasing number field by 1 with Custom Code

SOLVE

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!

0 Upvotes
JTBuys
Solution
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Increasing number field by 1 with Custom Code

SOLVE

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

ABrandt
Member

Increasing number field by 1 with Custom Code

SOLVE

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.

PamCotton
Community Manager
Community Manager

Increasing number field by 1 with Custom Code

SOLVE

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, and @JTBuys any recommendations for @ABrandt matter?

 

Thank you,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes