Help with Sequential Key Generation and Conditional Logic for Teams and Team Members

Hi AppSheet Community,

I am working on a scenario in my app and would appreciate your guidance on setting up some logic for key generation and selection conditions.

Scenario:

Key: A sequential number (1, 2, 3…) that needs to be automatically generated.

Team (Enum): A field where a team can be selected from a list of available teams (e.g., football, cricket teams).Team Members (EnumList): A field where multiple team members can be selected for a team.

Requirements:

  1. If only a team is selected, then all members of the team should be selected automatically and a key should be generated.

Catch: If 2nd step is followed , there should be no key generation in the next step,vice versa

  1. If a team is selected along with multiple team members, then a key should be generated, but:

No common members should exist across different combinations of teams and team members. If any member is repeated in multiple combinations, the key should not be generated.

  1. No duplicate keys should be created. That means the combination of team members (from the EnumList) should be unique. If the same combination is selected again, the key should not be generated.

How do I achieve this in AppSheet?

I need to ensure proper sequential key generation.

I need to enforce the conditions that prevent key generation when there are duplicates or common members across selections.

Thank you for your help!

Before you dive too deeply into an implementation, you’ll want to assess your need. Ask yourself…Why is it required to have sequentially numbered keys? Is there another way to do the same thing without sequential numbers?

Out of dozens of requests for sequential numbering, I have yet to see a use case that TRULY needed it. My STRONG recommendation is that you avoid sequential numbering at all costs. Trying to implement them can cause serious app issues.

Deeper Explanation…

There is no general implementation anyone can offer you that will 100% work in generating sequential numbers. The reason is because AppSheet operates in a distributed fashion - meaning EACH user has a copy of the datasource and operates independently of everyone else. Simply put, this means that if 2 users perform the same exact operation at nearly the same moment, they will both be assigned the same sequential number for different data rows. Not good!!

Some App Creators succeed in creating an implementation that works but only because they don’t encounter certain use cases that would make it fail. The danger is they MIGHT in the future have an occurrence of duplicates and without manual intervention it could cause app issues that become serious.

I hope this helps!

2 Likes

Yeah I can keep combination or unique or i do concatenate using other columns I’d for the key but I need condition for these scenarios logical expression/condition.

Serial Numbers, If You Must

2 Likes

Hi Steve ,I do get the serial numbers using max function but I need a logical condition to write valid if.

2 Likes

It appears you want to assign each team a unique number but only if all of the team’s members are only on that one team and no members are already on another team. At the end of the day, each player should be a member of only one team and each team should have a unique key. Is this interpretation correct? If yes:

ISBLANK(
  FILTER(
    "Teams",
    AND(
      ([_THISROW].[_RowNumber] <> [_RowNumber]),
      ISBLANK(
        INTERSECT(
          [Team Members],
          [_THISROW].[Team Members]
        )
      )
    )
  )
)
2 Likes