Hack to make versatile ref-like actions

behavior
references
(Kirk Masden) #1

Postscript: When I began writing this, I didn’t fully understand the similarities and differences between the navigational actions that are automatically attached to ref columns and inline actions that can be manually associated with columns. Now I understand that both kinds of actions make it possible for us to create something that looks like this:

51

Though they can look the same, there is an important difference between ref actions and inline actions: Ref actions allow us to draw the label from data in the table being referred to. In my own experience, this can be a crucial difference if one is having trouble with a lag in update times due to syncing. In AppSheet, not all columns in all tables are recalculated simultaneously. So, a select() expression that references another table may not yield a number that is immediately up-to-date, while a label from a referenced table may. In the image above, I wanted the Session statistics column to display the correct “Cards left in D to W” number without delay. I was able to accomplish this with a ref column but not with an inline action. The “hack” I explain here can allow you to take advantage of this feature of a ref column and still get the versatility of an inline action.

By the way, if you are having trouble getting calculations to appear correctly immediately, without waiting for a sync to finish, you may also be interested in this tip of mine:

===================================

User generated actions are cool. They greatly expand the range of app building possibilities. Now that several years have passed since AppSheet introduced user-generated actions, it’s hard to imagine how we got by without them. Unfortunately, placement within a page can still be a problem. Here are the official choices we currently have:

54

“Display inline” tucks the action into a spot that is accessed by tapping the upper right-hand corner of the screen. [Postscript: This is not entirely correct. “Display inline” can attach to a text of line. I didn’t understand this usage when I wrote this.] It can help one avoid clutter but has various drawbacks. “Display overlay” and “Display prominently” are useful but too many such actions make a cluttered screen.

Ah, if only we had cute little actions that could be placed at the end of a line of text – like a ref!

09%202

Well, as Glinda the Good Witch said to Dorothy in the Wizard of Oz, “you’ve always had the power, my dear, you just had to learn it for yourself.” Our “ruby slippers” are system-generated ref actions. Here’s how to utilize them:

  1. Make a ref the old-fashioned way.
  2. Go to “Behavior” in the app and copy the system generated ref action that is a “Go to another view within the app” action but is not editable by mere mortals.
  3. Now that the action has been copied it can become any kind of action you choose. I haven’t tried all of the possibilities but it seems that the entire range, including “Grouped: execute a series of actions,” is available. It’s also possible to choose a different icon.
  4. If one does not use a slice, we now have two actions that appear after our text (see below). This may be fine in some cases. However, if you want to control which actions appear after the text and which do not, a slice can be used to accomplish that.

09

That’s it! I hope you have found something in this post that you can use. :slight_smile:

4 Likes
Ref columns used with slices from the same table
(Steve Coile) #2

This also how the compose email button is attached to Email columns, and how compose SMS and start call buttons are attached to Phone columns, among others.

1 Like
(Kirk Masden) #3

Thanks! I haven’t worked with those functions. I take it, though, that they are similarly “hackable.”

(Fabian Weller) #4

Nice article Kirk.
In this way you can also add inline Actions in a table like “delete”.
Screenshot_1

Or these little angles to change the order in a table:
Screenshot_2
Just create a Virtual Column of type “Text” with the expression:
""
and attach the Action to this virtual column.
You can even attach many Actions to one virtual column.

1 Like
(Kirk Masden) #5

Thanks @Fabian! Perhaps you know about a method that I’m still unaware of. When you say

how is that done? Is that done in the way I indicated or is there another way to do that?

(Fabian Weller) #6

It’s as you said. “Display Inline” and “Attach to column” then choose the Virtual Column.

1 Like
(Kirk Masden) #7

Wow! This is embarrassing. I thought I had found something new but now I realize that I had never understood the “Display inline” option to begin with. Now I see that it does exactly what I thought my “hack” would do. Well, at least I know now. Thanks for telling me. I think I’ll write a note to indicate that my post is based on a misunderstanding. Thanks for your helpful response.

#8

You can attach the inline actions to a normal column as well.inlineActions

2 Likes
(Riki Armstrong) #10

I found it very useful and learnt a lot from your post.

2 Likes
(Kirk Masden) #11

Thanks @Riki_Armstrong! This has been a real learning experience for me. Today, I realized that there is an important difference between ref columns and columns linked to inline actions. I rewrote the “Postscript” I placed at the top of my post to describe that difference. Since ref columns can do things that inline actions can’t, now I think that this may be a useful “hack” after all.

2 Likes