Do a Search for a Thing's List of Fields (Introspection)

I would like to see a do a search for a thing’s fields, i.e. introspect and return all the fields of data type.

This would be very useful for:

  • Creating drop downs where you want the user to select the field of the thing dynamically.
  • Viewing a thing’s list of fields and values via a repeating group.

In fact in practice, at the moment I would like to do a dynamic filtering using operands and and or to search for multiple criteria dynamically. Currently my options are to hard-code (or hard-no-code) each field, which requires updating the system each time new fields are added and it does not allow selecting the same field in multiple sub-clauses of the search query. The better way would be to have a selection of the field via a drop down populated dynamically with the data of the thing and a value.

Something like:

First, I agree with your comment. That would be a great convenience.

Second, personally I couldn’t live with the “in practice” options so a while back I came up with a solution. I’m not saying you should want or need to implement this. I’m just providing it as an option and example of what can be done in Bubble even now.

Full disclaimer: I wrote this as a proof of concept. It could be made into a plugin for easier implementation (and probably someone already has, I honestly didn’t care to look)

Use a server script to pass in a Data Type (properties.thinglist1 is “Do a search for Persons:first_item:converted to list”):

Store the list of field names in a custom state (of type text - is a list):

Use the state as a data source (in my example I used it in an RG as I was building sortable headers):

Output result:

2 Likes

I have something for you both @umiumansa, @bubble.trouble… I made a plugin version of this:

Reminder: I work for tips - GRUPZ: Karma-Ware Plugins for Bubble

3 Likes

@bubble.trouble this element plugin version is a lot more efficient (faster) than sending that request to the server, though your idea and code are quite clever! :slight_smile:

@umiumansa this can give you dynamic field labels. Check out the Output Options. Let me know if there’s some variation you can’t get here that you might want.

Demo page here (very simple, but as with all my plugins there’s documentation for every field) that includes a link to the editor: https://list-shifter-dev-test.bubbleapps.io/version-test/fielder?debug_mode=true

Note that there are no actions in this plugin, but it does trigger an “Initialized/Updated” event when its fields change and it has published the new field values (though there’s really no need for that to ever be used).

Plugin is forkable if you wanna see how I build plugins or tweak the code to your specific needs.

5 Likes

You’re a world saver @keith Thank you.

1 Like

@Keith From one NG to an OG nice to see you active again. You made quick work of that :).

Thanks for always making your code available so the rest of us can stand on the shoulders of giants.

2 Likes

@keith first of all, thanks for your help.

I’m facing a problem with your plugin as you can check in the link below.

This is error:

The plugin Missing plugin / element Fielder threw the following error: TypeError: Cannot read properties of undefined (reading ‘toUpperCase’)
at eval (PLUGIN_1663789938547x316869486314782700/Missing-plugin-initialize–Fielder-.js:61:164)
at Array.map () (please report this to the plugin author)

Could you help me?

Oh, I guess it might not support empty values. I’ll look at that sometime soon but that error also says your plugin is “missing” you might need to reinstall it?

But actually … what you’re probably doing is passing a list of items. What you send it is a SINGLE example of the desired Thing (so like, Search for Thing:first item). It expects a thing, not an array of things.

(Correction: That’s not the problem. Sorry!)

Hey @fp1, upgrade Fielder to v 1.0.5 and let me know here when you’ve done that. This version writes some debug messages to the console so I can see what’s happening. (It’s not obvious to me why it fails for your things, but we shall see!)

Thanks for support @keith

I’ve just installed v 1.0.5.

1 Like

Will check that out in the morning!

Oh, OK. I see the issue. Looks like dash characters (and others) result in internal Bubble field names that have multiple underscores, not just single underscores between the words.

@keith I removed all weird characters you mentioned and it works. Thank you very much.

Do you know if is there some way to change a table name?

The main one has a acute accent :frowning:

Well, @fp1, I didn’t mean you should change those names, I meant that I had identified the problem and will fix.

I just pushed version 1.0.8 of Fielder, which I believe fixes the issues that @fp1 observed. I also caught another couple of issues that would make Fielder not handle things quite right. Should be much more broadly useful now! (My original 1.0.6 fix wasn’t very great. I also found a couple of User system fields that I had neglected to handle. Anyway, this little plugin is rather better now.)

Reminder to anyone who finds Fielder useful (or instructive)… I work for tips - GRUPZ: Karma-Ware Plugins for Bubble

1 Like

Thanks @keith

It worked using last version but with a particularity: Changes on field names don’t reflect on Fielder Lists

Is that expected?

Yeah, all we can get here are Bubble’s internal representations of the field names. These are created when you first make the field and, if you change the field’s label, that does not change how Bubble references it internally.

What Fielder does is takes the internal field names and pass them back to us, with or without some formatting.

If you turn on debug mode in the latest version of Fielder, it will log some console messages that show you what your field names look like internally.

Hello @keith
I was researching topics related to dynamic fields and came across this post.

I was wondering if, following this same line of thought of your plugin solution, Would it dynamically identify one field of a Datatype (under a given conditional) within a repeater group? Or …do you have another way to do that?

I need something similar to the following screen. Could you give some help? (Thank you :slightly_smiling_face:)