Forum Academy Marketplace Showcase Pricing Features

Reference fields of selected data source from dynamic expression?

Goal

To allow a Bubble developer to reference any field of a specified App Type from within a dynamic expression when defining a plug-in action.

Details

I’ve defined a plug-in action which contains a field of App Type. That is, I specified AppType as the value for the Editor field. This works as expected - i.e. it presents a list of app data types from which a single value can be selected.

What I want to do now is create a field that enables the Bubble developer to input a dynamic expression; and within that dynamic expression, the Bubble dev should be able to reference fields within the data type they chose in the App Type field.

I thought the “Fields of <selected App Type>” option might do it. It doesn’t. Instead, it renders as a dropdown and thus restricts the choice to just a single field within the chosen data type.

I don’t understand why that limitation exists. Is there no way to allow a Bubble dev to construct a dynamic expression that references ANY field within a selected App Type?

Consider the following hypothetical (and somewhat contrived) example…

Let’s say the fields Name, Hair Color, and Occupation have been created on the User data type. I want to allow the Bubble dev to construct a dynamic expression such as the following…

<Name> has <Hair Color> hair and works as a <Occupation>.

Stated another way, why don’t references to any selected App Type (such as User in the example above) appear in the list when editing a dynamic expression for a plug-in action?

I hope I’ve explained my question well enough. Does anyone have any insights? Am I overlooking something?

-Steve

1 Like

Ok, here’s a simple visual depiction of the functionality I’m trying to replicate. This is from Bubble’s native Map element…

Simply put, the user (Bubble dev) would specify a data type and a data source, and then they’d be able to reference fields of the specified type from a dynamic expression input (Marker caption in the example above).

I think I have a mental block, as the proper approach is eluding me. Has anyone done this and have any insights to share?

-Steve

EDIT

I’m still at a bit of an impasse on this. Since there’s been no reply, I’m guessing nobody’s seen this post, nobody knows the answer, or nobody cares. :crazy_face:

@keith and @vini_brito, I’ve seen other list-related posts by you guys. Do you have any thoughts to share? Is what I’m attempting to do simply not possible? Is there no way to allow the user (Bubble dev) to construct a dynamic expression that references fields of a selected list data source?

2 Likes

Of course there are cases and cases, but I usually approach this kind of stuff with more simplicity, like simply having a text field, or list of texts field.
That usually solves 99% of the cases for me.

Maybe I got used to work within such simpler structure and solve everything with it :yum:
There’s always a “Bubble-fu move” that can accompany the plugin, there’s no need to solve everything in the logic within a single interface inside the plugin.

I mean, there’s a single workflow action that I worked on for a bit more than a month part time and there’s quite a lot of logic in it, but even that one is accompannied with a good how-to-use and doesn’t uses “app type”.

I actually have the “app type” field as a last resort, to be used only when everything else wouldn’t cut.

Thanks @vini_brito, I appreciate you taking the time to respond.

I’m certainly with you on the “keep it simple” philosophy. Of course, the question then becomes, “Simple for whom?” In my experience, software that’s easier to use is generally more complicated to build. (Bubble itself is a testament to that.)

In this particular case, the editor UI that I was trying to build was close enough to that of the Google Map element that I became frustrated when I couldn’t figure out how to replicate it in my plug-in. Oh well, I guess I was thinking (hoping actually) that I was overlooking something.

I’m sure I’ll figure out an acceptable compromise. :slightly_smiling_face:

1 Like

Yeah, indeed we can’t build something exactly like that, BUT, and that’s a big “but”, we can build a similar experience, this is the goal of this example I built for someone who wanted a similar experience but in Leafy Maps, perhaps it may help as an inspiration:

Run mode: https://pdf-conjurer-testbed.bubbleapps.io/version-test/thing_by_index?debug_mode=true

Edit mode: https://bubble.io/page?type=page&name=thing_by_index&id=pdf-conjurer-testbed&test_plugin=1562697922620x934462587697889300_current&tab=tabs-2

Two way communication between map and standard elements/workflows to select specific object and filter lists.
To the end user it’s the same, for the app maker it requires a bit Bubble-fu but with a demonstration then it’s no problem. Of course the simpler the better, but this one is good enough… at least to me and to the person who needed it :sweat_smile: :yum:.

2 Likes

Hey Steve,

That would be really nice to have! One workaround I have used is using the ‘Fields of app type’ option and giving the user 3 or 4 of those fields that can be specified and then also giving them placeholders they can add in their text that correlates to a specific ‘Field of app type’ selection.

So maybe *FIELD_1* as a placeholder and in the action JS replace that with the value of the field specified in dropdown 1.

It’s not optimal but can give the users some options.

Eli

1 Like

Thanks, @eli. I appreciate the input! (no pun intended)

A token approach did actually occur to me. The biggest drawback, it seems, is that it wouldn’t allow “drilling down” into fields which are themselves objects (which is one of the most powerful aspects of the expression builder). To use the GMap example above, one couldn’t reference “User’s Pet’s name”. As you say, though, it does at least provide some options.

Then I looked at the Array of keys / values option, but that didn’t seem to offer what I need. Still not clear on how one might use it. When the need arises, I’m sure it’ll become obvious though.

Anyway, thanks for the idea!

Can anyone verify my suspicion that Bubble blocks access to the ‘User’ app type? Maybe @jared.gibb ? I have done it with ‘App Types’ such as ‘Customers’ and then with instance.data.customers = properties.customers.get(0, properties.customers.length()) you can access the ‘dynamic value’ of ‘field of type customer’ ‘name’ by running instance.data.customers[0].get(properties.name)

1 Like
var x = properties.thing.get(0, properties.thing.length())

var fieldname1List= x.map(x=>{
return x.get(properties.fieldname1)
})

^^^ so much more efficient than pulling in individual lists of typed data!
I’m not actually sure. I can test this out later today!

Are you trying to do this for the whole user list? I’d you’re running into issues, could it have to do with privacy rules?

when I console.log(properites.user_source) I can see the object
Screen Shot 2021-07-29 at 2.12.40 PM

but when I add console.log(properites.user_source.get(0, properties.user_source.length()) i get back undefined

My Test App only has two users and over 100 customers and it works just fine with customers which is why I am wondering if for security reasons or something bubble doesnt allow access to users

Check those privacy rules. Wanna post a screenshot of how they are set currently?

Not sure what I did. I walked away for a minute, came back to my computer, refreshed and now I am able to access the users. Thanks for the input.

1 Like

What I think I had to do, which seems odd, is do a seperate Search for User’s field on the plugin element and now it works. Even though I am not using that field for anything.

1 Like