Assign a number or code to each contact

forms

#1

Is there a way hubspot can assign a random code/number to each contact that fill outs a form?


#2

Hi @Etasla,

There’s no built-in functionality to assign a random number to a contact. You could likely implement this functionality by customizing to form embed code to include a short script in the onFormReady callback function. Perhaps something like this, which populates the randomNumber field with a random number between 1 and 10:

hbspt.forms.create({
    portalId: '{{ Hub ID  }}',
    formId: '}{ form GUID }}',
    onFormReady: function($form) {
        $('input[name="randomNumber"]').val(Math.floor((Math.random()*10)+1)).change();
    }
});