# problems with custom code not updating data output

**URL:** <https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240>\
**Category:** Data Hub\
**Tags:** workflow-extension\
**Created:** [April 21, 2025, 8:47pm UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240 "2025-04-21T20:47:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CWhite36](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@CWhite36](https://community.hubspot.com/u/CWhite36)\
**Post date:** [April 21, 2025, 8:47pm UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240/1 "2025-04-21T20:47:06Z")

</div>

im using some code to check all contact email addresses within hubspot for their dmarc status to inform those contacts to improve their cyber security.

const dns = require(‘dns’).promises;

exports.main = async (event, callback) =\> {  
const email = event.inputFields[‘email’];  
console.log(‘Email received:’, email);

let dmarcResult = ‘Invalid or missing email’;  
let checkedDate = new Date().toISOString().split(‘T’)[0]; // Format: YYYY-MM-DD

if (email && email.includes(‘@’)) {  
const domain = email.split(‘@’)[1];  
console.log(‘Domain extracted:’, domain);

try {  
const records = await dns.resolveTxt(`_dmarc.${domain}`);  
if (records.length \> 0) {  
dmarcResult = records.map(r =\> r.join(‘’)).join(‘\n’);  
} else {  
dmarcResult = `No DMARC record found for ${domain}`;  
}  
} catch (error) {  
dmarcResult = `DNS lookup failed for ${domain}`;  
console.log(‘DNS error:’, error.message);  
}  
}

console.log(‘DMARC result:’, dmarcResult);  
console.log(‘Checked date:’, checkedDate);

callback({  
outputFields: {  
dmarc\_status\_2: dmarcResult,  
dmarc\_last\_checked: checkedDate  
}  
});  
};

it doesnt seem to be mapping to the 2 data outputs i have created - dmarc\_status\_2: dmarcResult (as a string) and dmarc\_last\_checked (as a date)

Any ideas?

---

<div class="post-metadata">

**Author:** ![RubenBurdin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rubenburdin/32/75212_2.png) [@RubenBurdin](https://community.hubspot.com/u/RubenBurdin)\
**Post date:** [April 22, 2025, 2:32am UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240/2 "2025-04-22T02:32:10Z")

</div>

@CWhite36 this one’s tricky because everything in your code actually _looks fine at a glance_, but the issue likely isn’t in your logic — it’s probably in the way the **custom code action is configured inside your workflow**.  
Here’s what I’d check:

1. **Make sure the output field keys exactly match the internal property names** — in HubSpot, the property names are not always the same as the label you see in the UI. Double-check that your property internal names are truly dmarc\_status\_2 and dmarc\_last\_checked. One small mismatch and HubSpot will just silently ignore the output.
2. **Confirm your output fields are mapped in the workflow step** — in the custom code action, you need to **manually define the output fields** in the right-side panel of the workflow editor. If those aren’t declared and saved there, HubSpot won’t accept the values you’re sending back with callback({ outputFields }).
3. **Watch for return timing or async behavior issues** — unlikely in your code since you’re using await properly and calling callback() only once, but if there’s _any_ unhandled exception before callback() runs, HubSpot will treat the step as incomplete and not map the fields. You could throw a try/catch around the entire function just to be safe.
4. **Check field types** — if dmarc\_last\_checked is a **date property** , HubSpot expects it in **UNIX timestamp (milliseconds)**, not ISO string. So you’d want to do:

`const checkedDate = new Date().getTime(); // returns UNIX ms timestamp`

Let me know if it’s still not working after that — I can help debug the workflow side too if you send a screenshot of the setup.

Hope this helps.

![RubenB_0-1744951380316.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/a3b971f388794f90704ee697c25d92cf1613f49a.png)

**[Ruben Burdin](https://www.linkedin.com/in/ruben-burdin/)**

**Real-Time Data Sync Between any CRM or Database | Founder @[Stacksync](https://www.stacksync.com/) (YC W24)**

---

<div class="post-metadata">

**Author:** ![CWhite36](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@CWhite36](https://community.hubspot.com/u/CWhite36)\
**Post date:** [April 22, 2025, 9:36am UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240/3 "2025-04-22T09:36:48Z")

</div>

Thank you RubenB

I have updated the unix timestamp code. This is the workflow, not long at all.

 ![CWhite36_0-1745314393897.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/0/70fe8d071250e4e15b2f8ed984ec93d2b34e5cbf.png)

 ![CWhite36_1-1745314466309.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/1/017c0c3003806674538d8853f6cc28c90f31d7b1.png)

 ![CWhite36_2-1745314482032.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/3/6326a31320e3b9c31bfaccc761f76e19134749cb.png)

I have run a test on an existing contact which appears succesful

 ![CWhite36_3-1745314567489.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/e/be321d59b0629804aa109f6b12225b5edabee3b8.png)

I then checked the tested contact and data hasnt been populated in the fields in the crm.

---

<div class="post-metadata">

**Author:** ![RubenBurdin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rubenburdin/32/75212_2.png) [@RubenBurdin](https://community.hubspot.com/u/RubenBurdin)\
**Post date:** [April 22, 2025, 4:16pm UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240/4 "2025-04-22T16:16:17Z")

</div>

@CWhite36 Nice work  
At this point the missing link is how those outputs get written back to the contact record. In HubSpot, a custom‑code action **doesn’t automatically push its output into the CRM** ; the values just become tokens you can use in later workflow steps.

Quick fix:

1. Right after the custom‑code action, add a **“Set property value”** (or “Copy property value”) step.
2. Choose the contact property you want to update—dmarc\_status\_2—and in the right‑side token list pick the output token with the same name. Do the same for dmarc\_last\_checked (use the datetime token from the code step).
3. Save and re‑enroll a contact. You should see the fields populate a few seconds after the workflow fires.

If you’d rather handle it all inside the code, you can use the HubSpot Client to do an update on the contact right before callback(), but the extra “Set property” step keeps the code simpler and is easier to maintain.

Double‑check the internal names (looks like you’ve got them right), then re‑run the workflow on a test contact and the values should show up in the CRM.  
Ping back if it’s still blank—we’ll dig deeper.

![RubenB_0-1744951380316.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/a3b971f388794f90704ee697c25d92cf1613f49a.png)

**[Ruben Burdin](https://www.linkedin.com/in/ruben-burdin/)**

**Real-Time Data Sync Between any CRM or Database | Founder @[Stacksync](https://l.stacksync.com/hubspot) (YC W24)**

---

<div class="post-metadata">

**Author:** ![CWhite36](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@CWhite36](https://community.hubspot.com/u/CWhite36)\
**Post date:** [April 28, 2025, 11:44am UTC](https://community.hubspot.com/t/problems-with-custom-code-not-updating-data-output/130240/5 "2025-04-28T11:44:26Z")

</div>

Ruben,

Many thanks for the solution, this has now been fixed and all working smoothly.

Thank you again for the help.

Chris
