Actions with Variable


Just exploring the platform for the first time, and I have a simple inventory database with the following fields:

Serial Number, Asset ID, Building, Cart, Slot

I want to assign an action that a user can “Swap” an inventory item, so that it CUTS the Building/Cart/Slot number of the current record and can PASTE those same fields into a new record that’s looked up.

I can’t seem to find a way to do this with Actions…looking for Variables, perhaps?

1 Like

Keep in mind that AppSheet operates on a row based processing model. There are no intermediate/temporary storage mechanisms such as variables. However, your need IS completely within the capabilities of AppSheet.

How I would handle this is by introducing a Swap record that has 2 references to your inventory table - A Swap From reference and a Swap To reference. This is user supplied input. When the Swap row is saved then you can use a Workflow (with a series of actions) to automatically copy values from the Swap From reference into the Swap To reference. Then follow-up with a final series that removed the values from the Swap From columns.

I’ll leave it fairly vague there so you can ask for the help where you need it. It is not hard to do just need to understand how AppSheet operates.

1 Like

By the way, I meant to add this before, by introducing a Swap object/row into your data set, you will then have the capability to “remember” what was swapped and perform UNDO functions later. If values change after the Swap is done, you might need to record the specific values used during the swap but you now have the mechanism you can expand to add that “memory”.


Hi John…

Thanks for your answer, and it sounds like that is a logical way to go… so Swap record would essentially be another table that uses Ref fields to pull and then push?

Correct. A new table that has the columns Swap From, Swap To and then any other data you want to associate with the swap action. This table basically becomes your “variables”.

1 Like

Hi John…

Still struggling with the setup of this… my logical workflow is this:

Look up an inventory record (FROM) + hit Swap button…

  • Look up new inventory record (TO)
  • Change data of a TO record’s columns to be the value of FROM
  • Set value of FROM record column to blank

In the real world, I have a device with Building, Cart, and Slot number and need to replace it with a new device… the new device will have the updated Building, Cart, Slot number and the old one would be blank in those fields

All of my data lives in a single Google Sheet’s DATA sheet, with SWAP sheet being where the SwapFrom and SwapTo columns live.

Did I connect these properly?
How do I reference the SwapFrom record in an Action…meaning, what’s an example of the syntax where I reference a table/column?

Thanks again!

Brian, I apologize for the delay. I got busy and then when I started to reply, I realized my approach might have been overly complicated for your needs. It was based on a more complicated use case I developed last year for splitting an inventory item into two or more other inventory items.

I didn’t want to lead you down a rabbit hole so I created a little tester app to prove out the functionality. Typing out the instructions will be unwieldily so I can instead just transfer ownership to you so you can look at how I put it together. I would need your AppSheet ID and email to transfer.

The main gist is I scrapped the Swap table. Instead I added a Swap From column to the Data table. It only shows when a Swap is performed. Using a Swap action, the Swap view is automatically populated with the Swap From record and the Building, Cart and Slot fields are automatically initialized based on the Swap From record. There are other ways.

Once the “swapped” record is saved, a Workflow rule is triggered that calls an action (set of actions actually) to clear the fields from the original Data record that was swapped from.

Let me know if you’d like me to transfer the app to you or if you have any other questions.

Hi John I have a similar issue and was wondering if you might know how to solve. In the brewery I work at I’ve made a batches table for a record of all the batches we create. I also have a batch movement table which shows a record of the movement of batches between tanks as we filter a batch or move it for some other reason. Then I want the current status of tanks(Which batches it contains and the volume) to be displayed as some slice or in a different place holder table. The issue I’m running into is the fact that the tanks have different volumes so it can’t be simple swap. It has to be some volume transferring from tank to tank and then if the entire tank is transferred only then can the previous tank can be set to empty. Otherwise both tanks contain some volume of the same batch. The tank can also partially be packaged from or completely emptied with packaging. Is the app you speak of able to teach me something with regards to solving this? Any help would be greatly appreciated @WillowMobileSystems

@Heino_Matthee We shouldn’t hi-jack this thread with your question. I’ll send you a private message but if you’d like to keep the question open for others to chime in, please create a new post in the Questions area.

1 Like

Good afternoon, I need to set a value in a form drop-down, so that a user does not have to change it all the time. Is this possible with AppSheet?

If you mean to initialize it with a default value when the form first opens, then yes. You just need to set the Initial Value to one of the possible values in your drop down list.

If that’s not what you meant then please elaborate.

Also, as an FYI, this was posted under an existing comment from months ago. Only a few users will see message this way. It would be better to open a new question item so more people see it and for a general faster response.

1 Like