Need Help saving to Database - Spent hours trying to figure this out (and it should be easy?) Images included

I’m having an issue saving (creating/updating) a data base thing. Please see below for additional details of the issue.

This first image is of the main CRM screen. When I want to add a new item (PROSPECT), I have the Add Prospect button which opens up a popup.



This popup opens and the data type is PROSPECT. I have a reusable element that contains the Milestone dropdown. When the dropdown is selected, it creates a Custom State with the milestone name.



When the information in this popup is filled out, I have a Save button to initiate the workflow. Step 1 of the workflow saves all the PROSPECT data. That works as intended.



Here is where I get stuck. In the 3rd step of the Workflow, I am trying to save the milestone selected to PROSPECT>MILESTONES>milestone. In other words, while the MILESTONE is a separate data type, it is linked to the PROSPECT data type.



Here is the data type structure. You can see how the Milestone field links to the MILESTONE data type from within the PROSPECTS data type.



Here is the MILESTONES data type. There is a field called Milestone that I am trying to update and have that linked back to the PROSPECT. While all my instructions seem correct (i.e. at least not generating an error), there is obviously something I am missing.



I know I could just have a PROSPECT field called Milestone (text) and save to that, but I am using the MILESTONE data type to provide categories and color options.

Any ideas on what I can try? Any other information needed to help figure this out?

There’s only room in here for 1 Doug. I challenge you to a fight to the death.

3 Likes

I am doug4, once you challenge and beat the other 3 Doug’s, then you will have my attention!

2 Likes

What I see off the bat is you’re trying to save a type, that’s already the type you’re saving. So maybe change the Milestone from a text to a Prospect of type Prospects

Can you elaborate please. Are you saying to change the data type MILESTONE’s field called Milestone to type PROSPECTS? I’m not following the logic, but I learn by doing even if I don’t fully understand it at first.

Didn’t you say that the “Milestone” field is to link to a Prospect?

I did, I guess that makes sense. I will give it a try and report back.

If I understand what you’re trying to do… Where you’re going wrong is that you don’t desire to change a Milestone, you’re just desiring to set the Milestone field on the Prospect to be some existing Milestone object.

So you can do this in your existing Step 1 (just like you set any of the other fields on the Prospect), or as Step 3 (though unless you really desire to change the Milestone itself in some intervening step this doesn’t make a lot of sense). But step 3 would be Make Changes to the Prospect > what field to change? > Milestone > what value? > blah blah blah default milestone

Yes, that is correct.

So for this to work, would I need to create a PROSPECT field called Milestone? As long as I can still call on the MILESTONE data type to assign colors, etc., this would be easy enough.

Here is what I get when I try to do this in Step 1…

You already have a field of type “Milestones” on your Prospect. The field is named “Milestone”. (Also, yes, your naming convention is a bit wacky having named your Things in the plural. This is a common mistake so don’t feel bad.) However, I don’t quite understand your confusion.

Are you getting hung up on the fact that Things can have fields on them that are single or list instances of other Things?

It’s just like if a field is of type number. You can assign a number to a number field.

If you have a thing called a Prospect and thing called a Milestone, well, a Prospect can have a field of type Milestone (and vice versa). Just as you might assign 5 to a number type field, you can assign some particular Milestone to field of type Milestone.

Interesting, so Data Types shouldn’t be plural? When I think of things like users, it seems like it should be plural, since it will be storing information for multiple users. Easy enough to correct.

No, not confused about that. My sole source of frustration is trying to save the Milestone text to the data type Prospects. I can’t seem to figure it out. No matter how I structure it in the workflow, it doesn’t allow me to save it. Sorry I am having such a hard time explaining this.

Thank you for your insight, I will keep moving forward.

If a Milestone is a Thing, you don’t save the Milestone’s name. You literally save the Milestone itself in the field of type Milestone. (Under the hood, Bubble makes that connection via the Thing’s unique ID field, but you do not need to worry about that.)

Let’s take this out of your particular app. Suppose that I have a Thing (a custom data type) defined in my app that allows me to define a Pet. A pet might have a Name field, a Species field and a Breed field or whatnot, yes? And now I can create a specific Pet named “Fluffy” who is a Cat, and a Persian cat at that. And I then can create a specific Pet named “Rover” who is a Dog, and a Springer Spaniel.

Let us say these are the only two Pets in my database. “Do a Search for Pets” will return to me a list of Pets. The first item in the list is the Pet object that represents Fluffy the Persian Cat. The second item in the list is the Pet object that represents Rover the Springer Spaniel Dog. These are not strings (texts), they are the Pet itself (the object that represents the Pet). Here are those Pets in my data tab:

And now on my User type I have a field of type Pet (and the field’s name is Pet). This field allows me to associate some Pet with some User.

Well if some User is the guardian of Fluffy, to make this connection, I will put the Pet representing Fluffy as the value of the User’s Pet field.

Here’s another view of all the Pets. This time in a repeating group in some page:

Now a User comes along and say, “Oh hai, Fluffy is my pet!” and they click the button. Let’s put the Pet for Fluffy on the Current User:

As for plural naming of Things: If you define a data type of “Milestones”, when you “Do a Search for…” that data type, your expression will look like “Search for Milestoness” as just one example. Does that not make you insane? :slight_smile:

@keith First of all, thank you very much for your help and extra details, your time and expertise are very much appreciated.

I thought that was what I was trying to do. For an example, when the milestone input field is set to ‘Contacted’ by the user, I am trying to save this under the Prospect’s Milestone field.

But that’s the problem. It won’t let me save it. In your example, you are saving Current cell’s Pet to the Pet field under user. In my case, I am trying to save the Milestone Input (text) to the Milestone field under Prospect. It just won’t let me.

Here is the screenshot of the workflow showing the error:

It doesn’t allow me to save the Input’s Value to the Milestone Field under Prospect. Maybe I am still confused, but isn’t this what you were doing in your Pet example?

If I go into the App Data section and manually assign the Milestone, it works as expected:

Do you see what I am doing wrong?

Now that you mention it, yes, it does bother me. I’ve fixed this so they are singular now. :slight_smile:

I’m going to assume here for a moment that a Milestone is some admin-created object. Like, you have defined a set of Milestones that represent things like “Got Her Number”, “Called Her and Asked Her Out”, “Went on Date”, “Didn’t Get Past First Base”.

If so, you wouldn’t use a free text input to get those, you’d use a Dropdown (or perhaps a Searchbox), right? Because that will return to you the Milestone itself (like a Pet) not a string that’s the name of the Milestone.

In your case where you have a text input, that input’s value is just a text (a string). It’s not a Milestone.

If you Milestones have unique Names (for example), to get the Milestone named with the string “Contacted”, that expression is:

Do a Search for Milestones [constraint Name = that_text_input's value]: first item

:point_up:"find the Milestone in my database whose name is “Contacted”

NOW, if instead, Milestones are just an object with some arbitrary name and those names don’t have to be unique (that is, the User can just create a Milestone and give it any damn name they want), then what you are looking to do is:

Step 1: Create a New Milestone (and set its name to the value of that text input)
Step 2: Create a New Prospect (set all of your fields to whatever - you set the value for the Milestone field to be Result of Step 1: Create a New Milestone)

1 Like

Yes sir, that is correct.

I technically created a custom dropdown made of inputs and buttons, but I assume this would be viewed the same as text input. I will try just using a regular dropdown to see if that fixes it.

I’ll report back later.

So that was it! I added in the dynamic dropdown box, constrained the search to show the correct options, and then saved that value to the prospect. Everything worked exactly how I was expecting all along once I used the default dropbox.

I was never aware that you couldn’t save a input or custom state as a text and not have it recognize that the string matches with the linked database field. Do you think that is the intended action, a limitation bubble, or is that how it is supposed to work?

Marking you answer as the solution, that you for your expert help and education.

@doug.burden Thank you as well. We’ll fight to the death later :slight_smile:

2 Likes

No, that would not be desirable behavior. A string is a string. If the string represents something to you that doesn’t mean it automatically means anything anywhere else.

Now that you know how to do all of this properly, you might consider not just storing the last Milestone, but making a list of (maybe call it) “Interesting Moment” (as Marketo would have it) so you could record not just a Milestone, but also when that Milestone was hit. The possibilities are endless, of course.

Just glad u got it worked out!

1 Like

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