javascriptformsmarketo

How to submit data from one Marketo instance to another one?


We are having a hard time finding a way to send data from one Marketo instance to another Marketo instance. How would we send the data on form submit from one Marketo instance to another one?

We thought to use the form2.0 API, but couldn't find a way to send it since the current MktoForm2 variable is based on the account id, host url, and form id.

Scenario:

What we tried that didn't work:

MktoForms2.loadForm("//app-123.marketo.com", "785-UHP-775", 1057, function(form) {
    form.onSuccess(function(values, followUpUrl) {
        var currentVals = form.vals();
        //send data to instance ABC
        MktoForms2.loadForm("//app-abc.marketo.com", "785-UHP-775", 1025, function(form) {
            form.vals({
                'email': currentVals.email,
                'phone': currentVals.phone,
            });

            form.submit();
        });
    });
});

Solution

  • Try the following with return false; to prevent redirection of outer form to allow for inner submit() to occur as well as a couple of semantic changes including using different names for the different forms within callbacks.

    MktoForms2.loadForm("//app-123.marketo.com", "785-UHP-775", 1057, function(form123) {
        form123.onSuccess(function(values, followUpUrl) {
            var currentVals = form123.vals();
            //send data to instance ABC
            MktoForms2.loadForm("//app-abc.marketo.com", "785-UHP-775", 1025, function(formAbc) {
                formAbc.vals({
                    'email': currentVals.email,
                    'phone': currentVals.phone,
                });
    
                formAbc.submit();
            });
    
            // prevent redirection from happening of outer form
            return false;
        });
    });
    

    Hopefully that helps!