SMS workflow - is it possible to initiate a group text from AppSheet

Iโ€™m building a Staff/Contacts table. In addition to individuals/individual contacts, I am also creating groups as records within this table - i.e., โ€œManagementโ€, โ€œAdminโ€ - that would include an [EMAIL] and [CELL PHONE] column with entries as a list of comma separated email addresses and phone numbers (respectively). I would like to use this table as my official departmental contacts and allow all staff to initiate either emails, and/or SMS message from a detail view in my app. Iโ€™ve noticed that I can send an email from a details view that includes group [EMAIL] in the To: of an email. However, when I attempt to text from a group (comma separated phone numbers) only the first number is pushed to the message app on my phone (iOS).

Is it possible to initiate group SMS text message from AppSheet?

Solved Solved
0 8 1,787
1 ACCEPTED SOLUTION

@Steve @Phil Thank you both very much! I got the expression to work as I wanted. The final format (with my table/column names)โ€ฆ

SELECT(
OAR STAFF[CELL PHONE],
IN(
[KEY],
SELECT(
STAFF GROUPS[STAFF KEY],
IN([GROUP NAME], [_THISROW].[TEAM]),
TRUE
)
),
FALSE
)

I added the second IN expression - IN([GROUP NAME], [_THISROW].[TEAM]) - because [TEAM] is an ENUMLIST selection and I was getting an expression error (canโ€™t compare name to list).

Iโ€™ll probably cleanup my table and column names, replacing GROUP with TEAM, for consistency before I roll out this functionality into my production app.

Thanks again!

View solution in original post

8 REPLIES 8

Using a comma separated list wonโ€™t work.

Here is one way to model the group data that will work.

  1. Keep the Staff table as is with one phone number and one email address per staff member. However, remove all of the Group records from this table.
  2. Create a new Group table that contains one record per Group. Its key is GroupName. Add your groups here.
  3. Create a new GroupStaff table that contains one Ref to Staff and another Ref to Group.The Staff to Group relationship is a many-to-many relationship. The GroupStaff table allows you to model that. It will contain one record per Staff member per Group. For example, if โ€œPaulโ€ belongs to groups โ€œAโ€ and โ€œBโ€, then GroupStaff would contain two records. One record would contain {โ€œPaulโ€,โ€œAโ€} and the other would contain {โ€œPaulโ€,โ€œBโ€}.
  4. Now if your workflow email or SMS refers to a group, you can look up all of the group members in the โ€œStaffโ€ member and retrieve their email address or phone number.

@Phil Thanks! Iโ€™ll give this a try and will let you know if Iโ€™m successful

@Phil I setup my reference tables as you suggested - easy enough. Now Iโ€™m having trouble pulling in the email and phone numbers based upon a group reference. I think my trouble may be due to the fact that my [GROUP] selection is an ENUMLIST (?)

Iโ€™ve triedโ€ฆ

SELECT(OAR STAFF[EMAIL], IN([Related STAFF GROUPSs], [_THISROW].[TEAM]))

SELECT(OAR STAFF[EMAIL], contains([_THISROW].[TEAM], [Related STAFF GROUPSs]))

SELECT(OAR STAFF[EMAIL], contains([_THISROW].[TEAM], STAFF GROUPS[GROUP NAME]))

and various permutations of the above.

The best Iโ€™ve been able to manage is an expression that is valid, but doesnโ€™t pull in any data. Help please!

Your SELECT() statements will produce lists (possibly empty lists, but lists nonetheless). If youโ€™re trying to get only a single value, wrap SELECT() with ANY().

ANY(SELECT(OAR STAFF[EMAIL], IN([Related STAFF GROUPSs], [_THISROW].[TEAM])))

The above SELECT() format is the correct of the three you said youโ€™d tried.

See also: ANY(), SELECT()

At @philโ€™s requestโ€ฆ

The following expression would be suitable for use within the Group table, such as the app formula for a virtual column:

SELECT(
  Staff[Phone],
  IN(
    [Name],
    SELECT(
      StaffGroup[Staff],
      ([Group] = [_THISROW].[Name]),
      TRUE
    )
  ),
  TRUE
)
  1. SELECT(StaffGroup[Staff], ..., TRUE) gathers a list of distinct (per TRUE) staff which match the given criteria (..., see (2) below). โ€œList group members.โ€

  2. ([Group] = [_THISROW].[Name]) selects only rows of the StaffGroup table (per (1), above) with a Group column value that matches the current groupโ€™s Name. As noted above, this entire expression is intended for use within the Group table, where [_THISROW] would refer to a group row. โ€œIs this staffer a member of the group?โ€

  3. SELECT(Staff[Phone], ..., TRUE) gathers a list of distinct (per TRUE) phone numbers from the Staff table from rows matching the given criteria (..., see (4) below). โ€œList group member phone numbers.โ€

  4. IN([Name], ...) selects only rows of the Staff table (per (3), above) with a Name that occurs in the list of group members gathered by (1), above. โ€œIs this staffer in the group?โ€

Steve,

Can you help with writing the expression that does the following:

He has three tables (using my table names).

  1. Table โ€œStaffโ€ with key [Name], and field [Phone] and [Email] (This is the list of people with a name and phone for each)
  2. Table โ€œGroupโ€ with key [Name] (This is the name of the group e.g. โ€œAccountingโ€, โ€œSalesโ€, โ€œManagementโ€)
  3. Table โ€œStaffGroupโ€ with two ref fields. One to โ€œStaffโ€ the other to โ€œGroupโ€. (This is the many-to-many relationship table. It has one row for each group member. For example, if โ€œPaulโ€ is in โ€œSalesโ€ and โ€œManagementโ€ it has two rows {Paul, Sales} and {Paul, Management}

Starting with the โ€œGroupโ€ name, we want to retrieve the list of phone numbers of the members in that group.

You are much better at expressions than I am.

Thanks so much Steve. Really appreciate your help!

@Steve @Phil Thank you both very much! I got the expression to work as I wanted. The final format (with my table/column names)โ€ฆ

SELECT(
OAR STAFF[CELL PHONE],
IN(
[KEY],
SELECT(
STAFF GROUPS[STAFF KEY],
IN([GROUP NAME], [_THISROW].[TEAM]),
TRUE
)
),
FALSE
)

I added the second IN expression - IN([GROUP NAME], [_THISROW].[TEAM]) - because [TEAM] is an ENUMLIST selection and I was getting an expression error (canโ€™t compare name to list).

Iโ€™ll probably cleanup my table and column names, replacing GROUP with TEAM, for consistency before I roll out this functionality into my production app.

Thanks again!

Top Labels in this Space