Is it possible to make changes to a database entry in the plugin's update function?

For those of you wondering why would i need that when it can be achieved in the page editor, well…

Ever since I started using bubble i’ve had this problem (need help):

I cannot find a way to dynamically select a field of any given data type without conditionals.

For example:

Lets say I want to have a dropdown that displays the name of the fields of the User data type so that the choices are name or last_name (or whichever fields there are in the data type).
I could only achieve that with a plugin. :fearful:

Now imagine that I wanted to either change the name or the last_name and I wanted to select which one to change with the Dropdown.
I would set a workflow to make changes to a thing, set that thing to be Current User and then the expression I would use, if it existed, would be something like Dropdown A’s value = newString with Dropdown A’s value being the field i would be changing and newString being the new value.

For this case, since there are only two possible fields (name or last_name), a simple conditional works just fine. But when the amount of possible fields increases, using conditionals is just repeating the same thing over and over and i know that solving this with any sort of programming language is a one-liner. In Javascript it would look something like this:
User[“DropdownAs value”] = newString

For what i’ve researched this is not possible to do in the page editor.
Could this be achieved within a plugin?

I hope i explained myself correctly :upside_down_face:

To answer the question posed in the headline: No it is not possible to make changes to nor create nor destroy Things in a plugin. This can only be done by the Bubble programmer (much is the pity).

1 Like

Now, as for your other question: There is no notation in the expression builder that lets you specify a Thing’s field using a string (or anything else for that matter). You must construct, by pointing and clicking, some_thing's field. As you note, this is at times very tiresome.

1 Like

You could do something like this in your workflow, so all the fields are mapped but only the field selected in the dropdown is updated in one step

If you really want to use a plugin, you could create a data API (backend flow) and then call that API from your plugin (with Fetch or HttpsRequest)

2 Likes

Yep, that’s about as dynamic as you could have that in Bubble, @eldad1! For clarity, @sdcuru97, note that what @eldad1’s Make changes step does in fact make changes to all of the fields selected there, it’s just that the “updated” values will only be different for the field specified as the one to change.

2 Likes

Wow man! never thought of that!

While it is still more complicated than i think it should be i find this to be a great approach!

Thanks a lot!

2 Likes

Continuing the discussion from Is it possible to make changes to a database entry in the plugin's update function?:

Yes, still a lot of conditional formatting to do but much better than using a million steps with a million “Only whens”.

1 Like

I cannot find a way to dynamically select a field of any given data type without conditionals.

@sdcuru97

Don’t forget about using the Data API… (Make changes to a Thing by ID)

You can set the ‘field to change’ dynamically from a dropdown using that.

1 workflow action, no conditions, just one value for the field name, and one for the field value.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.