To set the value of [DEALERSHIP NAME] based on the user’s email when new rows are added for vehicles in the “DEALER CAR LOG” table, you can use the following App formula:
IFS(
USEREMAIL() = “user1@example.com”, “Dealership A”,
USEREMAIL() = “user2@example.com”, “Dealership B”,
USEREMAIL() = “user3@example.com”, “Dealership C”,
…
)
Replace the email addresses and dealership names with the appropriate values for your use case. This formula uses the IFS function to check the user’s email address against a list of predefined email addresses and corresponding dealership names, and sets the value of [DEALERSHIP NAME] accordingly.
To simplify adding new dealership names and user emails to the “DEALER INFO” table instead of making multiple expression changes in the app editor, you can use the REF_ROWS function to reference the “DEALER INFO” table from the “DEALER CAR LOG” table. Here’s how to set it up:
-
In the “DEALER INFO” table, create a column named [DEALER ID], which should contain a unique identifier for each dealership.
-
In the “DEALER INFO” table, create a virtual column named [DEALER REF], with the following App formula:
[DEALER ID] & “-” & [DEALERSHIP NAME]
This formula concatenates the values of [DEALER ID] and [DEALERSHIP NAME] to create a unique reference for each dealership.
- In the “DEALER CAR LOG” table, create a column named [DEALER REF], with the following App formula:
[DEALER ID] & “-” & LOOKUP(USEREMAIL(), “DEALER INFO”, “USER EMAIL”, “DEALER REF”)
This formula uses the LOOKUP function to find the [DEALER REF] value in the “DEALER INFO” table that corresponds to the user’s email address, and concatenates it with the [DEALER ID] value to create a unique reference for the dealership.
- In the “DEALER CAR LOG” table, create a virtual column named [DEALERSHIP NAME], with the following App formula:
INDEX(REF_ROWS(“DEALER INFO”, “DEALER REF”), 1, 2)
This formula uses the REF_ROWS function to create a list of all rows in the “DEALER INFO” table that reference the current row in the “DEALER CAR LOG” table, and the INDEX function to retrieve the value of [DEALERSHIP NAME] from the first row in the list.
With this setup, you can simply add new dealership names and user emails to the “DEALER INFO” table, and they will be automatically referenced in the “DEALER CAR LOG” table without needing to make multiple expression changes in the app editor.