Lists, Lead Scoring & Workflows


Custom code

Hi HubSpot, 


I am trying to create a workflow to update Email Sent Day based on 'Sent Date' metric available. I have created a custom field property (Email Sent Day) & a custom code to extract Day email was sent & update value (Email Sent Day). However, when i run the workflow, the custom field doesnt show any value. Can you help me check if my custom code or workflow needs any tweak?





exports.main = async (event, callback) => {
// Extract the 'sent' date string from the inputFields
const hs_email_last_send_date = event.inputFields['hs_email_last_send_date'];

// Replace '/' with '-' to create a format "dd-mm-yyyy" for Date parsing
const dateParts = hs_email_last_send_date.replace(/\//g, '-');

// Define an array of day names
const dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

// Get the day of the week as a number (0 for Sunday, 1 for Monday, etc.)
const dayOfWeek = new Date(dateParts).getDay();

// Get the day name from the array based on the day of the week
const dayName = dayNames[dayOfWeek];

// Define the 'email_sent_day' property in the code
const email_sent_day = dayName;


Use the callback function to output data that can be used in later actions in your workflow.
outputFields: {
email_sent_day: email_sent_day

1 Reply 1
Community Manager
Community Manager

Custom code

Hi @DGanasan,


Thank you for reaching out to the Community!

 I wanted to invite a couple of subject matter experts to this thread to see if they can help review the custom code action in your workflow:  

Hi @HFisher7@Teun@DanielJeal, do you have any advice for @DGanasan? Thank you! 


Mia, Community Team 

Wusstest du, dass es auch eine DACH-Community gibt?
Nimm an regionalen Unterhaltungen teil, indem du deine Spracheinstellungen änderst

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