Forum Academy Marketplace Showcase Pricing Features

Assign Items to Users. Possible?

I’m very new to bubble.is, so my apologies firsthand.

In simplest terms, It’s a private app. Users are essentially employees.

Simple for you all, yet excruciatingly difficult for me:

Two data types (thus far)… Users and Assets

When viewing an asset (page=assets), you may click a button to assign an asset to a user. When you view a user (page=personnel), you may click a button to see their assigned assets.

Please disregard the unorganized content and design. Any help or resources would be much appreciated. I’ve read manuals, taken a few lessons, and read a ton of the forum posts to no avail. Again, I’m new at this and just trying to figure it our like most.

Hi @jake.durham :slight_smile: Welcome to the forum!

Just took a quick look at the app. On the Asset page, I’m assuming after “Assign this Asset to an Employee is clicked” --> the User is selected from the dropdown, and that User’s information is then displayed in the inputs beneath it? (First Name, Last Name, The Asset’s Item Number and the Asset’s Item Name?).

Then when save is clicked you’d like the Asset to be added to the User’s List of Assets, and you’d like the User to be saved to the “Badge or ID Number” (User field) within the Asset data type? Can each Asset only be assigned to one User? But a User can have many Assets?

I used the badge number field as I thought it would delineate a specific user more accurately than trying to assign to a first name and last name (separate fields) of the user. So however would be easiest is fine by me. If you look on the Personnel page, you can click “assets assigned to this user” and in theory a list of their assets would be there. Of course, this list would be generated on the assets page by clicking the appropriate button. Does help help clarify?

No worries at all! :slight_smile: You’re definitely on the right track! Yes, that makes sense! One thing that might help is to change the name of the badge number field on the Asset data type to “AssignedUser” (keeping it as a User data type). In Bubble, every ‘Thing’ (or entry) in your database automatically has a unique ID. You don’t have to worry about assigning Users or Assets their own IDs because the unique ID field does this for you. (Here’s an example with more specific information on this: Things and List of Things confusion)

Also (I did the exact same thing when first starting out) it would be best to keep all data type names as singular, not plural. For example, ‘Assets’ should be changed to ‘Asset’. Otherwise it will be very confusing when looking at the Asset fields within each data type. For example, the User Assets field within the User data type currently looks like:

image

At first glance, this makes it seem like this is a list of Assets (since the s is on it). But after we remove the extra s from the data type spelling, we see this is just a single Asset field:

image

Yes, one way to store the Assets to a particular User would be to have a field within the User data type called User Assets (type: Asset, list: yes). Then the field will read as:

User Assets List of Assets

Then within the Asset data type, you can have an AssignedUser field (type: User, list: no - since each Asset can only have one User). This is probably the most simple method!

I don’t mean to overwhelm you (as I know this is all confusing in the beginning) but it definitely becomes easier! Feel free to let me know if you have any questions! :slight_smile:

1 Like

I really appreciate you providing some insight. It all makes sense. Knowing the types and fields have a unique id definitely helps, also. I’ll work further on the workflows tonight and hopefully obtain the results I’m looking for.

Thank you for taking the time to help me!

1 Like

No problem at all! :slight_smile: If you get stuck let me know and I’d be happy to take a look at the app again!

1 Like

Well, I have once again read the forums and used examples… no idea how I’m messing this up. Of course, upon visiting the asset page you have the option to assign the asset to an employee. The drop down in that group allows you to select a user, and the fields (item name and number) automatically populate with the parent group’s (RG of the list of all assets) current inputs. Not a problem there thus far. When you click “save”, however, not much happens afterwards. The save buttons workflow is changing a thing (a user)? It changes the user’s list of assign assets? Or does it change a list of things (user assigned assets)? Or maybe I should create a new thing each time? …

At any rate, I’ve tried multiple approaches to this, which I know will come very easy once this all clicks. Maybe just hint of direction on how to send this data to my user type data, or however I’m supposed to be do it. I swear I try to not bother folks on the forum, but I’m stumped!

No worries! :slight_smile:

In this workflow, though you have it as “Make Changes to a Thing”, there are no changes to the fields set up yet:

This is why you’re seeing nothing happening. Basically the action is telling Bubble “Make Changes to the Parent Group User’s ASA_AssignedAsset:first item”, but no fields to change. This expression is referencing the first Asset already in the Dropdown User’s ASA_AssignedAssets field, but this is not what you want because that would be modifying an Asset that is already assigned to the User.

Instead, we want to specify the Asset which the User was just viewing. Currently you have a Repeating Group which displays Assets on the page (before Assign this Asset to an Employee) is clicked:

Currently the Assign this Asset to an Employee button workflow shows the GP Assign Current Asset Group:

But it would be best to also display that Asset’s data in the GP Assign Current Asset Group. To do this we can add a Display Data action to the button’s workflow:

Then the property settings for the GP Assign Current Asset Group become:

The data type will always be “Asset” and the data source is empty be default. However, the data source becomes ‘filled’ dynamically when the Display Data action occurs (each time the Assign this Asset to an Employee is clicked) with the Asset data that the Current User is doing.

We can dynamically display this Asset’s information using “Parent Group’s Asset” in the Item Name and Item Number Inputs (this displays the Asset information that the User is viewing):

We can also reference the Asset in the Save button workflow here using the expression “Parent Group’s Asset” again:

And then Add that Asset to the Dropdown User’s list of Assets:

Then you can either set up workflows which hide the GP Assign Current Asset group after this workflow occurs, and add arrows within the repeating group to go to the next Asset. That should do it! :slight_smile:

2 Likes

Hey, I would to mention how incredibly helpful this submission was thank you !

I am trying to add an asset from a list of existing things inside bubble (list of things) to the current user. How can I do this same process but without the frontend ? I have “name” and “image” properties available to me in the list of things we are trying to pull from.

Any information will be greatly appreciated. Thank you.