Back to listing

Count the number of multicheck options selected

Category:
Custom-Coded Workflow Action, Operations Pro/Ent

ETL:
Transform

Notes

In our work at SpotDev, we keep encountering scenarios where our clients need to know the number of options selected in a multicheck property. 

For example, a company might contain information about the specific products a customer has purchased - the client needs that information and their reporting needs to know the total number of products they have. 

You can solve this problem a few ways. But, if you want to do so with a custom-coded workflow action, this function will count the number of items ticked/checked on a multicheck property and output the value as an int. 

You can then use a standard workflow action to copy the value of your output to a number property. 

Code

        

Language:



 

exports.main = async (event, callback) => {

  const valueList = event.inputFields['valueList'];

  let valueCount;

  const allValues = valueList.split(';');

  valueCount = allValues.length;

 

  console.log(allValues);

  console.log(`Number of values selected is ${valueCount}`);

 

  callback({

    outputFields: {

      valueCount: valueCount

    }

  });

}

How can SpotDev support your business?

HubSpot Migrations

Move from Salesforce, Dynamics, Pipedrive or any CRM to HubSpot with SpotDev.

Learn more

HubSpot Integrations

Add advanced functionality to your HubSpot portal with API development services.

Learn more

RevOps

Align your sales, marketing and service teams to break down silos and trigger growth.

Learn more