hubspot ops hub code formatter

hubspot operations hub custom code actions use event.inputFields for data and callback for results.

hubspot operations hub custom code actions let you run javascript in your workflows. your code has access to event (trigger data), hubspot (API client), axios, and properties (current object properties).

hubspot supports two code styles. the classic callback style uses exports.main = async (event, callback) => {} and returns data via callback(). the modern return style uses exports.main = async (event) => {} and returns data directly with a return statement. codefmt handles both patterns, wrapping your code in the correct structure before formatting and stripping it back.

the hubspot lint plugin catches common mistakes like missing callback calls, incorrect property access on event.inputFields, and validates globals specific to hubspot's operations hub runtime.

frequently asked questions

how do i return data from a hubspot custom code action?

hubspot supports two styles. the classic callback style uses callback({ outputFields: { key: value } }) to return data. the modern return style lets you simply return { outputFields: { key: value } } from your main function without needing the callback parameter. codefmt handles both patterns correctly.

what is event.inputFields in hubspot?

event.inputFields contains the data you configured in the workflow action settings. these are the custom properties you select when setting up the code action. you access them like event.inputFields.propertyName.

what is the difference between callback and return style in hubspot custom code?

the callback style uses exports.main = async (event, callback) => {} and you call callback({ outputFields: {} }) to return data. the modern return style uses exports.main = async (event) => {} and you return the output directly with return { outputFields: {} }. the return style is cleaner and now fully supported by hubspot. codefmt recognizes and formats both styles.

what globals are available in hubspot custom code actions?

hubspot custom code actions provide event (trigger data with inputFields), hubspot (the hubspot API client for CRM operations), axios (for HTTP requests), and properties (current object properties). when using callback style, the callback function is also available as the second argument. codefmt knows about all of these globals.

does codefmt catch common hubspot custom code mistakes?

yes. codefmt's hubspot lint plugin catches common issues like forgetting to call callback in callback style code, incorrect event.inputFields access, and missing return values in return style code. it also validates your use of the hubspot API client and suppresses false positive linting errors for hubspot-injected globals.