Using INPUT() to update another table using a value from this row

This “Tip” is a little report, with a sample app, on my own attempt to familiarize myself with the new INPUT() function. As @praveen has indicated, the advent of this function gives us the power of an “UPDATE EXISTING ROW(s) using values from this row” action:

Here’s a sample app I made to test this out:

https://www.appsheet.com/samples?appGuidString=502cc394-2717-4a69-8246-5fc26a1aa9cf

This extremely simple app has two tables: one with multiple records and one with only one record. The input function allowed me to make an action that takes a value (a word, in this case) from the record I happened to be viewing on the bigger table and then write it to the designated spot on the smaller table.

Here’s how I put it together.

  1. On the single record table I made the following action:

The expression is as follows:

Screen Shot 2021-07-16 at 13.23.12

In this case “Word_input” is just what I decided to call this function. You can make up just about any function name you want, I think. I set “AppSheet” as the default but in my application the default is just a placeholder because my app doesn’t use it; it always takes the value from the other table. So, I think the default value could be just about anything and it wouldn’t make an important difference in my app.

Before we go on, let’s take a look at how this action functions in isolation. In the app, I’ve set the action to display prominently with the label “WRITE WORD”:

I’ll hide this writing action when I actually use INPUT() in a working app of mine but I made it visible in the sample. If you tap on it inside the “Single word” menu, this happens:

Since the action hasn’t received a value for “Word_input”, it asks the user to provide it. The next step provides that value so the app doesn’t need to ask for it.

  1. On the big table, I made the following action:

Since “word_input” was part of the referenced action, I was able to select it and define it with a column name.

That’s it!! Works just fine!

input.2021-07-16 13_52_54

15 Likes

Great job, thanks for sharing this sample app !

3 Likes

Yes, good to see the new INPUT() function explained through an app. and your associated description/. Thank you @Kirk_Masden

4 Likes

@Kirk_Masden what a beautiful simple explanation. Way better than my complex wordy description. Thank you.

@Arthur_Rallu FYI

7 Likes

Thanks so much for your kind words, @praveen ! I think you have many different usages of this great new function in mind. I was only thinking about what I want to do in my own app, so I wasn’t burdened by the need to make a comprehensive explanation. :slight_smile:

By the way, you helped me with a problem I have been struggling with regarding how to improve the performance of an app that has lots of inline actions that link to URLs. I’m using INPUT() to deal with that problem. This way, even if I have a huge number of words to look up on one table I can simply make the app rewrite the word that the user wants to look up onto a tiny sheet (just a few records). Then, since the sheet is tiny, it can have dozens of virtual columns without getting too heavy – at least that’s my idea. I hope I’m on the right track. :thinking:

5 Likes

Thanks @Kirk_Masden
I might give this a test run . I have found lately that all the new “complex wordy descriptions” just make my head spin. Maybe Im getting too old for the new Appsheet. :slightly_smiling_face:

7 Likes

Thanks for the encouragement, @Lynn ! I had trouble understanding things at first and that led me to try to put a sample app together before attempting to use the function in one of my main apps.

4 Likes

@Kirk_Masden
I find that is a good way to learn also.

4 Likes

Great example here @Kirk_Masden . I just used it to build the same functionality.

One thing to note is that the “With these inputs” section on the “execute an action on a set of rows” Action might not show up right away. I had to set up the ref’d Action, with the INPUT() first, and then save the editor before it showed up.

4 Likes

Is there any reason the default value would not show up? I have tried both a static value of 20 and a dynamic value of a column within the row.

Actually, I don’t understand how the default works. I hope someone else can explain that.

The 2nd argument for the input() expression is said to be “default value” when the form is launched for entry, but actualy it is broken now (I simply suspect just because of bug) while it did worked before at the time when this new function was introduced. So currently, 2nd argument is not doing any jobs.

@Lusha_Wang1 should have idea and thoughts for us.

4 Likes

As 2nd argument is NOT working, so we are able to omit the same for now. Also, we are oddly able to omit the first argument (which is directing the target column name) as we select the name of target column withing action config.

The most simplest working expression syntax is as above. Looks strange to me, but it does work.

4 Likes

Thanks! I think, though, that you would need the first part (something like the following) if you wanted to call it up in another action:

 input("my_function_name","")

Right?

1 Like

on this document, the 1st argument is said to be

  • inputName ( Text ): Any input name that is unique within the context where it is used.

but actually we can omit, that what I said.

2 Likes

Wow! I suppose, though, that if we wanted to use the input function twice in one app (in two different ways), then we would need it. Thanks for the clarification.

1 Like

All in all, currently 2 x argument for this expression is not really doing any jobs, but input() expression is believed to be expanded further, so this story turns to be false in the future.

but

input("", “”)
input(" ", " ")
input( . , . )

those expression are valid (accepted by Expression Assistant), works in the same way.

It looks like KAOMOJI -style expression we are talking internallly…

("", “”)
(" ", " ")
( . , . )

3 Likes

Just some clarification:

There are currently 2 main uses for the INPUT() expression.

  1. Pop-up screen to allow manual user input to a column.
  2. Passing a variable from one record, through an “execute…” Action, to an Action on a different Record (possibly on another Table).

Kirk’s post here is more-so about the #2 usage.

In either use, you cannot “omit” either argument. A blank string is still a value being passed as an argument.

  • For use #1, the first argument is essentially not used for anything. The display in the pop-up comes from the column’s name/display-name/description.
  • For use #2, I definitely would recommend passing an actual descriptive value for the first argument, not a blank string.

The first argument is not a column name. You can think of it just as a variable name.

I also am experiencing that the default value does not seem to do anything currently.

6 Likes

That’s news to me :open_mouth:

2 Likes

I just tried using Input for the action
Add a new row to another table using values from this row.
However, the input doesn’t pop up on button click and just proceeds adding the row using the default values of the Input().

Does this mean that input is not designed for this action?

1 Like