# "Edit record" in workflows | add replace value with custom code output

**URL:** <https://community.hubspot.com/t/edit-record-in-workflows-add-replace-value-with-custom-code-output/146675>\
**Category:** HubSpot Ideas\
**Tags:** workflows\
**Created:** [February 25, 2026, 8:14pm UTC](https://community.hubspot.com/t/edit-record-in-workflows-add-replace-value-with-custom-code-output/146675 "2026-02-25T20:14:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FuriIshihara](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/furiishihara/32/229422_2.png) [@FuriIshihara](https://community.hubspot.com/u/FuriIshihara)\
**Post date:** [February 25, 2026, 8:14pm UTC](https://community.hubspot.com/t/edit-record-in-workflows-add-replace-value-with-custom-code-output/146675/1 "2026-02-25T20:14:03Z")

</div>

In our workflows, **we want to be able to replace the value of a date property with the output of a custom code action when using the “edit record” option.😊**

We created code in Data Hub that adds a month to a given date and sets it to “the 1st of the month.” When we get an error, it tells us to add a piece of code that prints the value to the property, which is a problem because we can’t connect to the API without an external integration and developer work.

The other option we were given is “edit record,” but we found that there’s no option to use this code! The moral of the story is, we’re stuck halfway.

I **t would be great if you could add this option, both for dates and for printing values ​​in existing properties.**

\*\*

 ![workflow edit record.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/3/834df445d130550a467bc470fa7382480d527053.png)  
\*\*

Thank you very much.

Code we added:  
// 1. ID del negocio desde el contexto del evento  
const dealId = event.object && event.object.objectId;

// 2. Fecha de cierre desde el input de la acción  
const closeDateStr = event.inputFields.deal\_close\_date; // clave definida en la acción

if (!dealId) {  
console.log(‘No se pudo obtener el ID del negocio desde event.object.objectId’);  
return callback(null, {});  
}

if (!closeDateStr) {  
console.log(‘No hay fecha de cierre, no se actualizará fecha\_de\_ultima\_renovacion’);  
return callback(null, {});  
}

const closeDate = new Date(Number(closeDateStr));  
if (isNaN(closeDate.getTime())) {  
console.log(‘Fecha de cierre inválida:’, closeDateStr);  
return callback(null, {});  
}

// 3. Calcular el primer día del mes siguiente (UTC)  
let year = closeDate.getUTCFullYear();  
let month = closeDate.getUTCMonth(); // 0 = enero, 11 = diciembre

if (month === 11) {  
year += 1;  
month = 0;  
} else {  
month += 1;  
}

const nextMonthFirstDay = new Date(Date.UTC(year, month, 1, 0, 0, 0, 0));  
const nextMonthFirstDayTimestamp = nextMonthFirstDay.getTime();

console.log(  
‘Negocio:’,  
dealId,  
‘Fecha cierre:’,  
closeDate.toISOString(),  
‘-\> fecha\_de\_ultima\_renovacion:’,  
nextMonthFirstDay.toISOString()  
);

// 4. Inicializar cliente de HubSpot  
const hsClient = new hubspot.Client({});

// 5. Actualizar la propiedad en el negocio  
await hsClient.crm.deals.basicApi.update(dealId, {  
properties: {  
fecha\_de\_ultima\_renovacion: nextMonthFirstDayTimestamp,  
},  
});

console.log(  
`Negocio ${dealId} actualizado con fecha_de_ultima_renovacion = ${nextMonthFirstDayTimestamp}`  
);

// 6. Devolver la salida opcionalmente  
return callback(null, {  
fecha\_de\_ultima\_renovacion: nextMonthFirstDayTimestamp,  
});  
} catch (error) {  
console.error(‘Error en custom code de fecha\_de\_ultima\_renovacion:’, error);  
return callback(error);  
}  
};
