js-webflow-api icon indicating copy to clipboard operation
js-webflow-api copied to clipboard

API returning different name for fields

Open jamesvclements opened this issue 1 year ago • 2 comments

My collection has a field named Summary: Webflow - Lux Capital-Wednesday-May-24-2023-02 53 03PM@2x

The API is returning the field as 'description-3': GET newsletter item - My Workspace-Wednesday-May-24-2023-02 54 33PM@2x

summary isn't found in GET or PATCH or POST calls. Is this the best repo to submit bugs to the Webflow API as a whole?

jamesvclements avatar May 24 '23 20:05 jamesvclements

This is not a bug. That field name on the API is set when you create the field, and never changes, even if you change it through the Webflow CMS. Once the field was created with the name X, it will always have that name.

Also, if you delete a field and create a new one with the same name, the new field will not be able to have the original name, say "summary". Webflow will always increment a number to the end of the field name so field names never repeat in the back-end.

What you can do to improve the work on your end is to create a helper function that gets the field slug from the field name. For that you will need to fetch the collection schema from the CMS API.

Jeandcc avatar Jun 15 '23 12:06 Jeandcc

Is there any way to deeply delete a field so that the field name is available again? It's especially inconvenient to work with dashes as object field names and makes types dirty with arbitrary numbers...

nlbdotdev avatar Oct 11 '23 20:10 nlbdotdev