Forum Discussion
Yeah that's fine, anything that works I will take a look.
------------------------------
Chris Baker
------------------------------
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
------------------------------
- ChrisBaker22 years agoQrew Member
This method seems similar to the one I thought about writing with the JSON API where I think you could
- create a relationship as usual, this will create a reference field in just the fields list
- use the JSON response on creation to get this new fields' id value
- use that field id and the update_field method to add the addToForm property to it and it gets added to the bottom
I will take a look at the XML version and see what I can do.
Thanks.
------------------------------
Chris Baker
------------------------------- Gary12 years agoQrew Assistant Captain
With the XML API add_to_forms is only handled when a field is created. Nothing happens if you update the attribute after the initial field creation. Maybe the JSON API is different, but I'm doubtful.
------------------------------
gary
------------------------------- ChrisBaker22 years agoQrew Member
https://developer.quickbase.com/operation/createRelationship
https://developer.quickbase.com/operation/updateField
It worked for me when using these operations in tandem but I could be mistaken.
------------------------------
Chris Baker
------------------------------