Custom field updates on Schedules

Hello,

I’m looking to track average time to contact for my deals, however some deals are automatically created when a requets comes in outside of workign hours and I do not want my stats to be skewed by this.

I want a custom field to copy the create data if the deal is created during working hours, and if it is outside of working hours I want to be able to set the custom field to the following working day at 9am as a create field.

I can only do this with custom code according to HubSpot support.

Can you help?

@HStocker - Its tough to tell about the overall context of your setup. But if its critical to make sure that deal create dates are withing working hours, it shoudl be possible to add a delay in the workflow that creates any deal to delay execution till 9am any working morning.

I would make the point that, from the point of view of your customers/clients, the start time of their expectations of feedback/service are when the request was submitted.

Hoping this is helpful.

Steve

Hello @HStocker,

Yes, this is possible, but it can be a bit tricky. The main challenge is that “working hours” and “working days” are highly individual. They vary between companies (and even teams) depending on country, holidays, company shutdowns, bridge days, etc. Because of this, there is no built-in standard solution that fits every use case.

The approach I would try is the following:

  1. Create a custom object or alternatively a HubDB (for example: Non-Working Days).
    Each record represents a date that is not a business day (public holidays, company holidays, special shutdowns, etc.).

  2. In your deal creation workflow, use a custom code action to:

    • Check whether the deal createdate falls within defined working hours.
    • Check whether the creation date is a working day by validating it against the Non-Working Days object (and weekends).
    • If it is a working day and within working hours, copy the createdate into your custom “SLA start” field.
    • If it is outside working hours or on a non-working day, set the custom field to the next valid working day at 9:00 AM.

This way, the definition of a “business day” is data-driven and fully configurable, instead of being hard-coded in logic that may not match your real business rules. It also makes the solution transparent and easy to maintain over time.

Did my post resolve your question? If so, please consider marking it as the accepted solution to help others in the community.
Kind regards
Dennis

Hey @HStocker

Thank you for posting in the community!

I found a community thread that offer more context for your issue:
https://community.hubspot.com/t5/Tickets-Conversations/Business-hours-delay-in-ticket-workflow/m-p/401610

I also want to tag a few community members to share ideas to help you find a solution. Hey there @kosalaindrasiri @SteveHTM @MichaelMa would you have any insights here? Thank you!

Victor

If you only need it to set a datetime field during working hours, that can be easily done without code using Workflows.

1. Create a Workflow for the deal.

2. Set the criteria to enter the workflow (eg, deal enters closed won).

3. Click the Settings file menu and then set the “Run actions on specific dates & times only” and set the schedule criteria you want.

4. In your Workflow, create an Action called “Edit Property”

5. If you set the action to update (replace) a field and select the option “use the date the action completes”, that should update it to be “now” (aka when the workflow runs).

Since this workflow will run only between X and Y times, deals that enter the workflow should “hold” until the allowed time and when it runs it will use the time the workflow action completes to fill the field.

It’s going to be slightly off from the Create Date field during working hours (maybe by a few minutes?) for deals that enter during working hours because Hubspot has to execute the Workflow.

eg, If a deal enters after 5PM, it will hold to 9AM but since the datetime field is set when the action completes, that might end up being saved as 9:01AM. Likewise for entering during the scheduled time, it may differ from the Create Date by a few minutes.