Adjust form values before the submission

Hi, Is there any way to apply a formula or expression on form values before submission? Let me explain. Imagine I am asking the user to enter her birth date and let say I want to calculate the user age and set it to the “age” field. I know I can set up the formula on Google Sheet and use ATTAYFORMULA, then when insertion happens, I let Google does the job. I want to know that is there any way we apply such an expression on input values before submission within the App itself?

Yes, you can do this.
Write the DOB to a temporary user specific column, then use a math column to calculate the age (now() - DOB). Then when the user submits the form, you can write the calculated age to the appropriate column.

Here is what your math column would look like:

Depending on your use case, the temporary column probably isn’t even necessary. You can just write the DOB to the table, and then use the calculated age for display purposes.

“Age” was just an example, but I take the idea. User-specific columns can be used to feed the backend (sheet) column—thx for that :+1: . I have one more relevant question, how about if I want to set a constant valuer for a column? One of the columns is “status”, and I want to set it to “pending” when the form is getting submitted. Fyi the “screen” sheet is different than the sheet this form is trying to submit. We have a screen that shows all subscription plans from sheet “Plans,” and for each one, there is a “subscribe” button. When they click, a form pops up to get extra information and then insert a new row in the “Subscriptions” sheet. That sheet has a column “Status” that I want to set “Pending” by default.

I know I can set a default value here, but I want to have the field in the form, while I can set the value, like screen columns or special values.

If you’re using a custom action on form submit, then you can do this quite easily with an Add Row action. One of the options with this action is to specify a custom value for any column. You can use this to set the status of the new row.

I guess just to add to that - and getting back to the topic of formulas in the Google Sheet vs calculated columns in Glide - as a general rule I try to avoid spreadsheet formulas as much as I can. This is because if you can do calculations in Glide, then your app will be much snappier. There are times when spreadsheet formulas (or scripts) are the only answer, but the Glide data editor is quite powerful, and with a little bit of imagination and creativity you’ll find that most things are possible.

2 Likes

Yes!! I did it, thank you! This Glide is getting more lovely :smiley: How you know all these things :)) And totally agree with you regarding the computation! I want to have an app as decoupled from Google spreadsheet as much as possible.

1 Like

Lots of reading, lots of trial and error, and a healthy dose of paying close attention to those that are way more knowledgable with Glide than myself :wink:

4 Likes

Well done, thats the key to mastery on almost anything.

1 Like