New item/row with defaults set from most recent

Hi,

Looking at the best options for creating an item/row that a selection of fields are defaulted on the last item entered historically.

The context is that an item is created that holds 12 “scores” of different measures 1 to 5, using the rating component. So the next time a user “scores” it would be useful to just change the ones that are different. This way the data retains the historic trends of the scores.

Now I have used ARRAYFORMULA, for post saving updates to fields (mark the most recent item and setting 0 to 1 for the ratings) but this new requirement requires a preceding event to default, not a post save event that ARRAYFORMULA can handle.

Any ideas?

Thanks Rich

If you have a user profiles, you can use a multiple relation column, matching the emails between the user profiles Sheet and the ratings Sheet (you should also have the email of the user in there, or use user-specific columns to store the ratings).

From that relation column, you can use a single value column to bring back the last ratings the signed-in user has submitted and use them as default values in the next form.

However I doubt that the rating component has a default value, the text entry, number entry and choice component does.

1 Like

I use this all the time. One thing I’m trying right now (and I feel like I have tried everything) is to calculate on the fly the default value for entry of distance driven. I have the last odometer saved (both on the vehicle record and on the user’s record).
image

It seems to me that if using USC for entering the data, we have access to what the user is keying in for IF-THEN-ELSE columns. I tried doing a simple MATH column to subtract last odometer from what the user enters in the current odometer, but MATH columns are not allowed columns for DEFAULT.

I’m quoting your post, but open to ANYBODY who has an idea of how I can structure the data to be able to give them the distance driven (having both the last odometer and the new odometer reading that they just keyed in) w/o having to save the record and come back into edit to plug in a distance for them.

If the distance driven is calculated, then they don’t need to enter it, right?
From your comments, it sounds like you’re using a custom form (writing the entered data to user specific columns), so what you could do is just display the result of your math column as a static value, and then save it when the form is submitted.

But… do you actually need to save it as a separate value if it’s something that can be calculated? :thinking:

Well, some people prefer to save their trip on the odometer and enter that value. My plan was to calculate the value for those who don’t prefer to do it that way or as a check-point for those that do.

And then there are those who won’t put an entry in at every fill, so the distance driven calculated would be way off the mark, and they need to put in the trip distance.

It’s all for having a diverse way to cover the most number of possibilities.

Okay, so… you want to give them the option of either entering the trip distance or accept the calculated value?

If that’s it, all you need to do is add an if-then-else column:

  • If user specific distance column is empty, then math column
  • Else user specific distance column

And then use the if-then-else column as the final value when the record is added/updated.

1 Like

Well, I’ll have to try that, but the reason I am asking is because I don’t see the value of the math column. I’d like them to at least see the calculation while entering the data. That’s what I’m having trouble with… I can store the former odometer reading in the record and do all the calculations later. I want to do it as they enter the data (so they can see it).

Why can’t you display the result of the math column on the form screen as soon as they’ve entered the new odometer reading?

The odometer reading is going into a user specific column, right?
So the value should be available immediately.
I normally use a hint component for these sorts of cases, and set the visibility on the hint component to only show when the user specific column is not empty - this makes it look “instant” to the user.

1 Like

That’s probably what I’ll have to do. I was actually hoping to make it the default entry value but the math column is not available for that purpose.

I think the only way you could do that is to make them tap a button after they enter the odometer reading. Then you could have an action that takes the calculated value and sets the distance traveled user specific column to that value, and then expose the entry component, allowing them to edit it.

Bit of a clunky user experience though…

2 Likes

Yes that was my thought as well. I’m used to programming in a language where we have the ability to respond to all sorts of events like onchange and Lostfocus. I’m also used to being able to set a default event for a button so that just tapping enter causes the button to react.

2 Likes

I have an app that I use to track fuel fills. I use a custom form where you enter the current odometer reading, the fuel price per gallon, and how many gallons. This form is driven from a user table.

The first thing a user does is select their vehicle. The selected vehicle is populated in their user row. Then I use rollups to get the max odometer reading from the log table for that vehicle. So now I have the previous odometer reading. When I open the form (through a custom action), I move that rollup value to a basic text value used in the form (default value). This allows the user to change the previous odometer reading or leave it as is.

Since everything is in a custom form, I then have enough information to calculate distance between the previous and current odometer reading, fuel economy, cost per mile, etc. before the form is even submitted. I think I calculate most of that in the log table, but it would be easy to do it directly in the user/form table so a user can see the results in real time before they click on submit.

2 Likes

My setup is almost identical. But it seems to me I’ve tried in the past to set the entries BEFORE doing SHOW FORM and have always had trouble. Do you add a record and then “show detail” or “edit detail”? How are you specifically moving the value? I have a table that is only used for input, and is all USC columns and computed columns. It is only upon submitting that a record is created in my “mileage log”.

I like that instead of using Glide’s “default”, you are just setting the value, but like I said, specifically how are you navigating this custom form?

*EDIT

I see you are asking a question before your custom form. I’m using a choice on the custom form, defaulted to the last vehicle they selected – I’m assuming every driver in the family has a favorite car. Once they’ve selected a vehicle on the custom form, I’m limited to what I can do. So I guess the first thing I have to do is modify that behavior and allow them to select the vehicle first.

I can choose the vehicle both inside and outside of the form. The key part is that I’m using a custom form, so I’m not using the Show Form action. I’m use a Show Detail Screen or Show New Screen action to view screen for a specific user row. In this case I’m using a Show New Screen action. I don’t use a choice component, but I use an inline list that sets the selected value in the user row. So when I select a vehicle from the inline list, I’m setting both the vehicle ID as well as setting the previous odometer reading (default value) from the log.

I think that’s the key issue that you are running into. You need an action when selecting a vehicle. Instead of a choice component to select a vehicle, use an inline list so you can execute actions when selecting your vehicle.

Here’s a quick video that shows my app. Sorry for going fast and for the lack of tap indicators. Hopefully it’s a little more clear how I do it.

2 Likes

ah yes, of course. Much better idea :+1:

2 Likes

Thank you so much for responding. I love the look and feel of your app.

You are exactly correct that I need an action. I’m certainly having trouble with the math column recognizing the entry of the odometer entry in the USC. But I’m going to incorporate a lot of your suggestions before I produce a video on that. Perhaps the problem will go away you never know.

Too late for me to tackle it tonight so hopefully sometime tomorrow.

1 Like

OK, I’ve spent some time playing with this, but I’m seeing that if I do not use a NEW FORM, Glide does not allow me to set a “default value” for a number entry or a text entry – nor even a date entry.

image

And while I was thinking “yes, using an inline list, I start with an action”, it was more along the lines of triggering actions on my NEW FORM.

I actually get to the NEW FORM with an action of a floating button.

So using a SHOW NEW SCREEN and setting it to detail (and hiding the Back button with CSS), I can set up a “cancel” and “save” button, and by setting up USC on the user record, I am actually getting the keyin of the odometer to be recognized by a “hint” and by a math column. But the distance I am calculating cannot be set into the number entry field because it does not accept “default value”.

I see how you are guiding the user along from entry to entry with a wizard of sorts, and I really don’t want it to work that way.

And I’m still not understanding why the USC were not working this way in my data entry table. I have a table where almost all the columns are USC, and when I was on my new form, I could use the USC to set visibility conditions, so I know they were being “set” by my keyins, but I could not use the value in a HINT or for the DEFAULT VALUE of any field – it’s like the USC were empty (this was using SHOW FORM rather than SHOW NEW against the USER table)

“Default” isn’t available outside of a form screen or add screen, and rightfully so. In any other case, such as an edit screen or a detail screen, you are working with values in an existing row, so normally you wouldn’t override an existing value with a default value. You would only set a default when you are adding a new row. A custom form is kind of a gray area where it’s used to add a new row, but you are still editing an existing row first.

I use a custom form because it provides more freedom to do math in real time, or establish relations with usable values, or perform additional actions within the form if necessary. For my use case, I think the vehicle list already has the previous odometer value pulled into the vehicle table, so when I select a vehicle, the set column action on the vehicle inline list writes the previous odometer reading into my custom form as a “default” value.

I now find it better to use a separate single row table to use for a custom form. This allows you to use a ‘Show Detail Screen’ action instead of a ‘Show New Screen’ action, which will allow it to be a reusable custom form that can opened from multiple places in your app while only having to set up the form once.

Curious why you would hide the back button. I can understand if you want the Cancel button to do certain actions, such as reset the form, but I think it’s better to reset the form on the way in instead of on the way out. That way a user can simply use the back button if they want or they can use the Cancel button, which would just be a ‘Go Back’ action. Keep in mind that hiding a back button with CSS is not foolproof… especially with android users that can simply use their hardware Back button instead of the Back button in the app.

I’m not sure I’m completely following the issue you are running into here. I do know that you cannot fill a USC column when you are in a native form or Add form. I guess I’ve never attempted to use a USC column to set a default, but if you are using the user profile table as the source of your default values, then you really shouldn’t be using USC columns in the user table. Everybody already has their own row, so there is no need for USC columns, since no one will be sharing the same row.

So this brings us to your core issue. I just want to make sure I understand how you want your form to work. So am I correct in assuming that you want a user to enter a current odometer reading, which would calculate a distance when subtracting the previous odometer reading, but you still want that calculated distance to be editable? This would not be possible in a native form with default values mainly because the defaults are set on the way into the form. Not while you are in the form. As for a custom form, you would need some sort of action to fire after the odometer reading is entered. That would only be possible with a button that a user would have to press. So if you had a sort of multi-step form, the button could not only move the calculated distance into the distance entry column, it could also set a flag to conditionally show the rest of the form.

I think you going to have to think outside the box to get this to work in glide. I realize the traditional programmer thinking of executing a function when losing focus on a textbox, for example, but that’s just not how glide works.

1 Like

What does your Cancel button do?

If it does anything more than “Go Back”, then you’re almost certainly going to have problems.
I learned this lesson a long time ago. I thought I was being clever hiding the Glide back “button” and “forcing” users to tap my own Cancel button. But my users had other ideas. Especially my Android users.

If your Custom Form flow relies on the fact that you’ve hidden the back button, then you are doomed. If you’re using your Cancel button to reset the state of the form, don’t bother. A much better approach is to set the state on the way into the form.

Bottom line: if your Custom Form flow relies on the Glide Back button being hidden, then it’s broken.

2 Likes

Yes it just goes back. For me it was a question of visual consistency. I wanted to have a left right button the left button to cancel on the right button to save. To me it looked strange to have a back button at the top which the verbage is unclear as to exactly what that means and then a save or commit or submit button at the bottom. Anything that I need to do is done when they 1st enter the form.

2 Likes