Form onFormSubmit getelement by js(serialize) or one best option


#1

hi everyone,
I'm David

I need some help for my work.
We need take the data form (form create on hubspot), when somebody pushs the button submit and this information is sending to hubspot and at the same time another server (local).
I am trying to make this through js (serializeArray()),
I need to create a file type json..
In this moment i have something like this.
.
{firstname: "Nombre", lastname: "Apell", phone: "3232323", company: "Compania", proyecto_interes: "Proyecto1", …}
company
:
"Compania"
email
:
"asela@hc.com"
firstname
:
"Nombre"
hs_context
:
"{"rumScriptExecuteTime":432.200000002922,"rumServiceResponseTime":698.500000002241,"rumFormRenderTime":174.10000000018044,"rumTotalRenderTime":702.8000000027532,"rumTotalRequestTime":168.09999999895808,"lang":"es","css":"","pageUrl":"http://cdn.nctech.com.mx/web.dev_2018/form.php","pageTitle":"php -> API","source":"FormsNext-static-1.893","isHostedOnHubspot":false,"timestamp":1525285486485,"userAgent":"Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36","referrer":"","hutk":"7e6d6cd438d656e99d2f523c52173e58","originalEmbedContext":{"portalId":"4151481","formId":"4bc3e43e-006d-4a51-9e2d-57f3419af120","locale":"es-mx","css":"","target":"#hbspt-form-1525285487403-9034479788","redirectUrl":"","inlineMessage":true},"recentFieldsCookie":{},"boolCheckBoxFields":"primer_capitulo,segund_capitulo,tercer_capitulo","dateFields":"","redirectUrl":"","smartFields":{},"urlParams":{},"formValidity":{},"formTarget":"#hbspt-form-1525285487403-9034479788","correlationId":"d2a64354-05b6-478d-b211-d1cad0f2a8cd","disableCookieSubmission":false,"usingInvisibleRecaptcha":false,"isFallback":false}"
lastname
:
"Apell"
phone
:
"3232323"
proyecto_interes
:
"Proyecto1"
segund_capitulo
:
"true"
tercer_capitulo
:
"true"

but I do not need all the information just from the form fields i want!

Maybe someone has another idea to make this, I'm open to proposals


#2

Hi @ilodi,

If you need to submit your form to an external location and to HubSpot, you're almost always better off creating a custom HTML form and submitting it to HubSpot via the Forms API. You can submit the form to your server & do whatever you need to do, and then pass the submission into HubSpot. I'd strongly recommend taking that approach since it gives you more control & flexibility.