Forum Discussion
Have you already created the fields and you just want to get them onto a form? Or do you want to create the fields and add them to the form automatically? Also, are they lookup fields or summary fields?
------------------------------
gary
------------------------------
I want to both create the fields and add them to the form in one post request. All of these fields are reference fields, so there has to be a dropdown menu that lets you pick the parent record.
------------------------------
Chris Baker
------------------------------
- Gary12 years agoQrew Assistant Captain
I don't think this is possible with the JSON API. The creation of lookup fields is vastly simplified, but at the cost of full field customization.
That said, this is possible using the good ol' XML API (or URL alternative). If you're interested, let me know and I'll pass along the details.
------------------------------
gary
------------------------------- ChrisBaker22 years agoQrew Member
Yeah that's fine, anything that works I will take a look.
------------------------------
Chris Baker
------------------------------- Gary12 years agoQrew Assistant Captain
It's a two-step process per field.
First, use this endpoint to add the new field:
https://helpv2.quickbase.com/hc/en-us/articles/4418302265236-API-AddField
At minimum, you'll want to pass mode, type, and add_to_forms. Type must match the field type of the intended lookup field in the parent table.
Also, make sure your legacy form is set to "Auto-add new fields". (I have no idea what will happen with the new form styles.)
<mode>lookup</mode> <type>text</mode> // must match intended lookup field! <add_to_forms>1</add_to_forms>
Second, use this endpoint to update the the lutfid and lusfid attributes of the newly created field:
https://helpv2.quickbase.com/hc/en-us/articles/4418310972052-API-SetFieldProperties
<lutfid>8</lutfid> // the field ID of the reference field in the same table <lusfid>6</lusfid> // the field ID of the source field in the lookup table
lutfid and lusfid are not in the XML API documentation, but they are visible when you call API_GetFieldProperties on a lookup field. For some reason, they are ignored when passed to API_AddField, but they are accepted when passed to API_SetFieldProperties.
I tested this out and it all works: the field is created, it's a lookup, and it appears by default on the legacy form.
IMO, this method is going to require a lot of overhead to script/automate. If I were in your shoes and this was a one-time operation, I would consider using the JSON API to create the fields (very easy) and manually add them to the form (painfully monotonous).
Good luck!
------------------------------
gary
------------------------------