Skip to main content

I am receiving website contact forms into, and passing details into mapped Hubspot fields. 
One of the form fields is a multi-select, where the values are received as an array of values. I’ve run the Run Javascript app, to convert the array of values to a single joined text string as an object. 

 

The “Run Javascript” result / output is successful, but when I try to map it to a single line text field in Hubspot, I get an error:

Invalid input JSON on line 1, column 370: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)

Below is the code I’m using:

 

// Initialize an empty array to hold the selections

let selections = e];

// Loop through the inputData to collect the options

for (let key in inputData) {

  if (inputData.hasOwnProperty(key) && inputDatamkey]) {

    selections.push(inputData.key]);

  }

}

 

// Mapping of form values to HubSpot expected values

const mapping = {

  'service': 'Service',

  'issuing': 'Issuing',

  'acquisition': 'Acquisition',

  'other': 'Other',

  // Add all your mappings here

};

 

// Map each selection to the HubSpot expected value

const mappedSelections = selections.map(item => mapping.item.trim()] || item.trim());

 

// Join the mapped selections into a comma-separated string (with space after comma for readability)

const result = mappedSelections.join(', ');

 

// Return the result wrapped in Zapier’s required format

const outputString = result.toString();

output =  {outputString} ;

 

Hi ​@Marelise 

Try this Zap action: Formatter > Utilities > Line Items to Text

Help links for using HubSpot in Zaps: https://zapier.com/apps/hubspot/integrations#help

 


Hi ​@Marelise 

Try using this Zap step: Formatter > Utilities > Line Items to Text

 


Thanks ​@Troy Tessalone  
 

I changed the “Code by Zapier: Run Javascript” step, and replaced with Formatter > Utilities > Line item to text. 

I used ; as the separator, and I’m getting the same error. 


The website form contained a multi-select, which the Hubspot side is expecting as a single line text value. 
Thinking that the multi-select is the thing making this tricky, I changed the form input to a single select (radio button) input. I adapted the Zapier formatter, to format the single select option (form output) into a sentence case text output. 
But when the info is passed to Hubspot, to create a deal / contact, I’m still getting this error:

Invalid input JSON on line 1, column 246: Cannot deserialize value of type `java.lang.String` from Array value (token `JsonToken.START_ARRAY`)


@Marelise 

For us to have more info, post screenshots showing how your current Zap steps are outlined and configured in EDIT mode with the field mappings visible along with the DATA IN/OUT for the steps.


Hi ​@Marelise,

 

To help you better, we would like to see how your Zap is set up. Please share screenshots of your Zap in edit mode, including the step outline, field mappings, and DATA IN/OUT sections. Ensure everything is clear and readable; feel free to blur out any sensitive info. Also, include a short description of your issue so you can provide more targeted guidance. Once you've shared your details, we'll be happy to help troubleshoot and optimize your Zap.