Is there a way to output the field ID of a field via a script? In this case I only get the file ID, but need the field ID
You can do something like this:
const response = await tape.Record.get(current_record_id);
const field = jsonata(`fields[label="Base"].field_id`).evaluate(response.data);
console.log(field);
just replace the βlabelβ with the label of the field you are after, I am not sure if that helps or not thinking about it as maybe you donβt have the label?
Jason
Will just enhance @Jasonβs great suggestion to use the script block with a little bit of API magic
When retrieving records via the API, you will only receive the populated fields, but not the empty ones. That is why retrieving a field ID via such a call is not ideal.
Indeed, a second call to the App
API will yield the full app config including all fields (link to docs).
Your code could look similar to this:
// load record ...
const record_response = await tape.Record.get(current_record_id);
// ... use app_id of record to fetch the full app:
const app_response = await tape.App.get(record_response.data.app_id);
// access your field as suggested by Jason
const field = jsonata(`fields[label="Base"].field_id`).evaluate(app_response.data);
console.log(field);
// proceed as required...
This will return all fields of the app, and should allow you to extract field IDs in any scenario.
Let me know how it goes!
Cheers
Tim
PS: I wiped a couple of responses from this thread, that were indeed unrelated (only caused by a typo / copy paste mistake) to avoid confusion. Above solution should resolve @Romanβs issue entirely.