Lists, Lead Scoring & Workflows

NGiron
Membro

How to split list in Workflow via Custom Code

Hello,

I am still new to hubspot, and I was told that the "Custom Code" feature in Workflow is still beta. Is there an example code snippet that I can use to grab let's say 10% of the list?

0 Avaliação positiva
4 Respostas 4
himanshurauthan
Autoridade no assunto | Parceiro Elite
Autoridade no assunto | Parceiro Elite

How to split list in Workflow via Custom Code

Hi NGiron,

Can you please share your workflow setup for which you want to grab 10% of the list? Or you want to execute the workflow for 10% of the enrolled contact?

 

Best Regards,
Himanshu

Digital Marketing & Inbound Expert In Growth Hacking Technology
NGiron
Membro

How to split list in Workflow via Custom Code

Hey Himanshu,

I actually wanted to execute the workflow for the enrolled contact.

In the screenshot below, I'm trying to add that 10% of enrolled contact to a new list.
flow.png

Kind Regards,
N

0 Avaliação positiva
NGiron
Membro

How to split list in Workflow via Custom Code

Hey @dennisedson 

Thank you for your response. Yes, that's the one. I'm testing this code but it's still sending to all of the contacts instead of 10%

 

const hubspot = require('@hubspot/api-client');
exports.main = (event, callback) => {
	return callback(processEvent(event))
}
function processEvent(event) {

    const hubspotClient = new hubspot.Client({apiKey: process.env.HAPIKEY});
    hubspotClient.crm.contacts.basicApi.getAll()
    .then(results => {
      
      let count = results.body.length();
      let percent = .1;
      let end = count * percent;
      
      results.body.slice(0, end);
    })
    .catch(err => {
      console.error(err)
    })
}

 




0 Avaliação positiva
dennisedson
Equipe de Produto da HubSpot
Equipe de Produto da HubSpot

How to split list in Workflow via Custom Code

Hey @NGiron 

Apologies for the late reply.  Are you referencing this

@MatthewShepherd @thesnappingdog , have either of you played with this yet?

0 Avaliação positiva