Looking to populate multi-checklist with enumeration from workflow

So we currently store multiple choice values in our internal database in a string with comma separated values. What I’m currently doing is, I’m splitting those values with a custom code block in a workflow:

exports.main = async (event, callback) => {
 /*****
 Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
 *****/
 const signupReason = event.inputFields['signup_reason_internal_array'];

 const signupReasonResult = signupReason.split(",");
 /*****
 Use the callback function to output data that can be used in later actions in your workflow.
 *****/
 callback({
 outputFields: {
 signupReasonArray: signupReasonResult,
 }
 });
}

The output is an enumeration of the values available in the multi-checklist:

What I’ve done as a next step is I’ve tried to use the copy property value action, but it’s giving me a very generic error:

How can I solve this or at least get a more verbose log of the issue?

Hey @CAntoniades,

I think I know what the issue is. I’ve recorded a video running through the proposed fix: Workflow Issue. (The first half is me trying to explain the issue you are seeing, the second half is me going through the actual fix! :blush: )

What I have opted to do is use the HubSpot Client to update the contact within the coded action instead of using the copy to property action. I believe there are some limitations to using the action when it comes to dealing with multiple enumeration values. The code I used (and reference in the video is below):

const hubspot = require('@hubspot/api-client')
const hubspotClient = new hubspot.Client({
 accessToken: process.env.HUBSPOTTOKEN
})

exports.main = async (event) => {

 const signupReason = event.inputFields['signup_reason_internal_array'];
 const signupReasonResult = signupReason.split(",").toString().replaceAll(",", ";");
 console.log(signupReasonResult)

 const properties = {
 "sign_up_reason": signupReasonResult,
 };
 const SimplePublicObjectInput = {
 properties
 };
 const contactId = event.object.objectId;
 hubspotClient.crm.contacts.basicApi.update(contactId, SimplePublicObjectInput).then(response => {
 console.log(response);
 })
}

I should also add that going down this route requires setting up a private app within your portal. This is so we’ve got an access token to authenticate requests to HubSpot. It also means that there are daily limits in place but HubSpot is quite generous in terms of their limits. Full overview here.

I hope that this is helpful in some way and points you towards a solution.

I just got back to this.. Thank you so much for the detailed response @coldrickjack , I managed to get it to work.