# Data Output not defined in code, tried other posts

**URL:** <https://community.hubspot.com/t/data-output-not-defined-in-code-tried-other-posts/127289>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [March 4, 2025, 3:08pm UTC](https://community.hubspot.com/t/data-output-not-defined-in-code-tried-other-posts/127289 "2025-03-04T15:08:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MBeauclair](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@MBeauclair](https://community.hubspot.com/u/MBeauclair)\
**Post date:** [March 4, 2025, 3:08pm UTC](https://community.hubspot.com/t/data-output-not-defined-in-code-tried-other-posts/127289/1 "2025-03-04T15:08:18Z")

</div>

I have been reading through past posts and trying to get my data output to work but still getting an error that it is not defined in code.  
I have a workflow that enrolls any contact where the a combined score threshold is known (I have them setup for each of our 8 products). Then the custom code will map the A1, A2, A3, etc to a string that provides a clearer next step for our sales team.  
the third step in the workflow would copy that data output string to a custom single line text property I have setup.  
Here is the code:

exports.main = async (event) =\> {  
console.log(“Received Event:”, JSON.stringify(event, null, 2));

if (!event || !event.inputFields) {  
return { “outputFields”: { “priority”: “” } }; // ✅ Explicit quotes  
}

console.log(“Available Input Fields:”, JSON.stringify(event.inputFields, null, 2));

const score = event.inputFields[“qc\_combined\_score\_threshold”];  
if (!score) {  
return { “outputFields”: { “priority”: “” } }; // ✅ Explicit quotes  
}

console.log(“QC Combined Score Threshold:”, score);

// ✅ Declare the mapping before using it  
const scoreMapping = {  
“A1”: “High Engagement × Ideal Buyer”,  
“A2”: “Moderate Engagement × Ideal Buyer”,  
“A3”: “Low Engagement × Ideal Buyer”,  
“B1”: “High Engagement × Possible Buyer”,  
“B2”: “Moderate Engagement × Possible Buyer”,  
“B3”: “Low Engagement × Possible Buyer”,  
“C1”: “High Engagement × Unlikely Buyer”,  
“C2”: “Moderate Engagement × Unlikely Buyer”,  
“C3”: “Low Engagement × Unlikely Buyer”  
};

// ✅ Ensure that the score exists in mapping, otherwise return an empty output  
if (!(score in scoreMapping)) {  
return { “outputFields”: { “priority”: “” } }; // ✅ Explicit quotes  
}

const label = scoreMapping[score]; // ✅ Always a string  
console.log(“Generated QC Lead Priority:”, label);

return {  
“outputFields”: {  
“priority”: label // ✅ Explicit quotes  
}  
};  
};

---

<div class="post-metadata">

**Author:** ![MichaelMa](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@MichaelMa](https://community.hubspot.com/u/MichaelMa)\
**Post date:** [March 4, 2025, 7:04pm UTC](https://community.hubspot.com/t/data-output-not-defined-in-code-tried-other-posts/127289/2 "2025-03-04T19:04:21Z")

</div>

If you create a new Custom Coded Action, the default code has output code:

```lia-code-sample
 callback({
 outputFields: {
 email: email
 }
 });

```

You will notice that it’s wrapped in a callback function. It doesn’t seem like your code uses a callback (yours just returns the data)?

---

<div class="post-metadata">

**Author:** ![MBeauclair](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@MBeauclair](https://community.hubspot.com/u/MBeauclair)\
**Post date:** [March 5, 2025, 3:20pm UTC](https://community.hubspot.com/t/data-output-not-defined-in-code-tried-other-posts/127289/3 "2025-03-05T15:20:34Z")

</div>

thank you, that’s what I needed!
