SOLVED

Re: Create a hidden form field via the REST API

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

Re: Create a hidden form field via the REST API

Best practice is a small set of global forms. Or if you absolutely must -- and are cloning from template programs -- exactly one form per program. Not a random assortment of one-off forms created by low-privilege users. The easier you make it to do the latter, the harder you make it to organize smart campaigns and automate processes in general.  I couldn't possibly encourage this: we routinely work with clients to reduce an explosion of unmanageable, unfilterable forms to a 1-5 flexible forms with advanced behaviors.

I know how to push leads into Marketo using API, but we need a solution for a step before. i.e. create from and fields in Marketo using the API.

Creating a form using the Asset API doesn't create fields in the database. It just binds fields to the form. And as I said it can't do what the Form Editor UI can do.

When you say you "know how to push leads into Marketo using API" do you mean the Forms JS API?  Because literally zero fields need to exist on a form you submit using the JS API.

Anonymous
Not applicable

Re: Create a hidden form field via the REST API

Yes, Forms JS API .... as described here http://developers.marketo.com/blog/make-a-marketo-form-submission-in-the-background/

In the documentation its clearly mentioned ....

"The important part is setting your fields and values correctly. Be sure to use the SOAP API name of your fields which you can find with Export Field Names to ensure correct submission of values."

So, I am not sure what you mean by "Because literally zero fields need to exist on a form you submit using the JS API."

If I don't setup the fields on the from, then how do I get the SOAP field names ? or am I really missing something here ?

SanfordWhiteman
Level 10 - Community Moderator

Re: Create a hidden form field via the REST API

The field just needs to exist in the database. Once you know its SOAP name, you can add it to any form with form.addHiddenFields(). There's no need for it to appear in Form Editor at all. 

Anonymous
Not applicable

Re: Create a hidden form field via the REST API

ok, I am not sure what "Form Editor" you are talking about ? I don't use Marketo interface much. I have only implemented/integrated the API using the steps mentioned here​ on standard HTML pages.

We have a Marketo administrator who creates the forms and fields in Marketo. He then provides me the form ID and SOAP fields names to code.

So seems like there is no way to create forms or fields using the API directly ....! Someone must login to Marketo and create form and fields.

SanfordWhiteman
Level 10 - Community Moderator

Re: Create a hidden form field via the REST API

There is a way (partially) to create forms, but no *need* to do so for your case.

You can add different hidden fields to the same single hidden form depending on the context/page it's on. That underlying form doesn't even need the 3 basic fields -- First Name, Last Name, and Email -- to be shown in Form Editor. Every field can be programmatically added on the client.

Anonymous
Not applicable

Re: Create a hidden form field via the REST API

Thanks Sanford Whiteman​ for all your replies. Really appreciate it. We will see, how it goes.

Cheers..!