SOLVED

Create a hidden form field via the REST API

Go to solution
Spenser_Fishel1
Level 1

I'm trying to add a field to a form via the REST API (this will eventually be done to hundreds of forms which is why I want to do it via the API) but I get a System Error when I try to set 'fieldType' to 'hidden'. When I run the 'Get Fields For Form' endpoint I see that 'dataType' is 'hidden' for the hidden fields, is the 'fieldType' declaration different (they seem to match on everything else)?

What I'm trying to run that is giving me the system error (personal data XX'd out).

Endpoint: https://###-###-###.mktorest.com/rest/asset/v1/form/XXXX/fields.json

Post Payload: fieldId=myField__c&label=HiddenFieldLabel&fieldType=hidden&access_token=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX:XX

Also, is there any documentation on how to set the Autofill settings for hidden fields via the API?

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

It's not you, it's the docs (which are not quite prime-time for these latest endpoints) and the server. This shouldn't cause an error.  I expect hidden hasn't been implemented correctly. Do you want to open a case, or should I?

View solution in original post

15 REPLIES 15
SanfordWhiteman
Level 10 - Community Moderator

It's not you, it's the docs (which are not quite prime-time for these latest endpoints) and the server. This shouldn't cause an error.  I expect hidden hasn't been implemented correctly. Do you want to open a case, or should I?

Anonymous
Not applicable

Hi Sanford Whiteman​ Is this fixed now ? We are looking to create form and fields using API ? Can you please help ?

Thanks

SanfordWhiteman
Level 10 - Community Moderator

I don't know if it's fixed, likely not.

Are you sure you need to use the Asset API to create forms? What's the use case?  This API still falls short of the UI-driven options.

Anonymous
Not applicable

Hi Sanford Whiteman

Thanks for your prompt reply. I work in a Uni. There are many content editors, they often need to create forms for various campaigns, events or other things, not everyone has access to Marketo to login and create/setup forms. So we were thinking of a way to give the non-technical editors the capability to create forms using our CMS and then automatically have this data inserted into Marketo.

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.

We can do the frontend/interface ourselves, all we need is an API that let us create forms and specify its fields.

SanfordWhiteman
Level 10 - Community Moderator

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

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

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

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

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

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

Cheers..!

Anonymous
Not applicable

Sandy!!!!

How come every time I am looking for information on a question, you are somehow involved with the answer?????????

SanfordWhiteman
Level 10 - Community Moderator

Because I'm the knowitalliest know-it-all who ever knew it all?

Anonymous
Not applicable

LOL!!!! You seriously made my day today. I want to know something! Anything!!! A penny to your dollar!!

Anonymous
Not applicable

Seriously! lol

Devraj_Grewal
Level 10 - Champion Alumni

He's a celebrity around these parts. Haha.