Cliffnotes- need to keep 2 tables a pure 1:1 relationship using a key (user name preferred) knowing that the 1st table changing is due to external influence and the app itself will not add nor delete any rows.
Looking for some advice for a simple overall schema. We are starting with a "user" table that is generated from a CRM. Eventually we would like to see our app sync directly with said CRM's database so, for today, I am setting the app up to use a sheet to simulate this (for future ease if/when change is made to point directly to CRM). The app itself is basically meant to add a bunch of semi-pertinent attributes (lets call these "details") to each user (using them to determine suitability, etc). These details are only being used by the app and actually have a life span thus they will never need to be retained long term. The app will not add nor delete any rows. So the subsequent "details" table is created in a Sheet with a direct 1:1 with the user table, with only needing a key value to connect the 2 tables. The obvious choice is user name or user email. As I learn more about AS and understanding the importance of the key, I may become more comfortable but let's be honest, using a key of user name is very readable/friendly. It also makes the use of system generated View Ref (Name) more functional (this is always the key, no?)
The catch here is that the user table may change over time and as it is regenerated, it is always sorted alphabetically. Keeping the details table in sync to always have a 1:1 matching row with the user table is easy from a Sheets perspective, via use of a formula in details (=UsersTable!A:A) referencing back to users (via the user name as the key). Thus my dilemma in AS as the key can not contain a formula.
In summary, I am guessing the solution to my dilemma is to just introduce a unique key as a new column and then I am free to use my formula(s) at will and thus, I will need to learn the various nuances to deal with various functions (ORDERBY(), etc) that require the key. With that being said (and please do correct where I'm mistaken) - are there any other methods to accomplish maintaining a 1:1 users:details relationship, remembering that the app itself, will not add nor delete any rows?
Hi @jharkless , it's not clear to me what should happen with details table when user table changes. If you use excel spreadsheet as database for user and details tables, you can have a key column in details table with UsersTable!A:A formula, but you need to put this formula into the excel sheet and not inside appsheet definitions. Everytime you change this column you will need to refresh data in you app.
Sorry for lack of clarity. The user table changing just means a new user has been added. My use of "Sheets" meant Google Sheets (same as Excel) and yes, I was referring to handling the formula in said spreadsheet.
With that said, my suggesting that this is easy to handle in a spreadsheet is a complete fallacy on my part. The moment the users table is changed, all of the matching data in details would basically need to be lookups My thought that the order of data rows in details matching that of users isn't necessary. Ugg, I clearly need to think through this a little more...
are there any other methods to accomplish maintaining a 1:1 users:details relationship, remembering that the app itself, will not add nor delete any rows?The catch here is that the user table may change over time and as it is regenerated, it is always sorted alphabetically. Keeping the details table in sync to always have a 1:1 matching row with the user table is easy from a Sheets perspective, via use of a formula in details (=UsersTable!A:A) referencing back to users (via the user name as the key). Thus my dilemma in AS as the key can not contain a formula.Appscript to maintain Sheets with trigger every specified time. In App Settings ->Performance - Quick sync ( or UX Behaviour- Offline/Sync- last on the bottom), also set on user long in set sync app.
In script replace database/rows you need.
In general, I see what you are saying about using AppScript (I have dabbled slightly with this already) to be the way to handle keeping these 2 sheets 1:1. I am actually thinking best to not even include AppSheet in the process to maintain these.
@jambyc wrote:In App Settings ->Performance - Quick sync ( or UX Behaviour- Offline/Sync- last on the bottom), also set on user long in set sync app.
I honestly don't know what you are suggesting to be options I want to use here
User | Count |
---|---|
16 | |
13 | |
8 | |
7 | |
4 |