Hello AppSheet Community,
I’ve encountered a strange issue when adding related records using the default +Add button associated with a Ref_Rows virtual column, specifically with a SQL Server data source. I hope someone might have insights or confirm if this is a known issue.
Setup:
- Parent Table:
Avances de contrato(Contract Advances) - Key:Row_ID(nvarchar(50)) - Child Table:
Multas por avance(Penalties/Discounts) - Relationship:
Multas por avancehas a column[Avance]of typeRefpointing toAvances de contrato. - Database: Microsoft SQL Server (Azure SQL in my case, Foreign Keys were removed for testing).
- Column Type: Both
Avances de contrato.[Row_ID](Key) andMultas por avance.[Avance](Ref column in AppSheet, FK column in SQL) are defined asnvarchar(50)in the SQL database. - Configuration:
- The
[Avance]Ref column inMultas por avancehasIs Part Of? = FALSE. Reset on edit? = FALSE.- No
Initial Value,App Formula,Spreadsheet Formula,Valid_If, orSuggested Valueis set for the[Avance]column. - No
Security Filteris applied to theMultas por avancetable. - No Triggers exist on the
Multas_por_avancetable in the SQL database. - My plan is Enterprise plus
- The
Problem:
- From the Detail view of a parent
Avances de contratorecord, I click the default+Addbutton (associated with theRelated Multas por avanceRef_Rows column) to add a new childMultas por avancerecord. - The form for
Multas por avanceopens correctly. Crucially, the Label of the parentAvances de contratorecord is correctly displayed in the[Avance]Ref field, indicating AppSheet knows the parent context. - I fill in other details and click “Save”.
- Locally (before sync), the app behaves correctly: the form closes, and the newly added
Multas por avancerecord appears in the related list within the parentAvances de contratodetail view. The pending sync indicator appears. - The app synchronizes, and the sync history reports “Success”.
- Issue: A few seconds after the sync completes, the newly added
Multas por avancerecord disappears from the related list in the parent detail view. - Checking the SQL Server database directly, the row was inserted into the
Multas_por_avancetable, but the[Avance]column (the foreign key reference) isNULL.
Workaround Found:
If I change the setting Is Part Of? to TRUE @the definition of the [Avance]column, within AppSheet, the problem disappears. This means, adding a new record using the same default +Add button, the [Avance] column value is correctly recorded, with the parent’s key (Row_ID) in the SQL Server database after synchronization.
Question:
Why does the reference value fail to persist to the SQL Server database (resulting in NULL) when using the +Add action for a relationship where Is Part Of? = FALSE, even though the reference is correctly identified locally and the sync reports success? Setting Is Part Of? = TRUE forces the correct behavior, which suggests a potential inconsistency or bug in how AppSheet handles persisting non-“part of” Ref column values via the default add mechanism specifically with the SQL Server connector.
Has anyone else experienced similar behavior with SQL Server? Is this a known limitation or a potential bug?
PS: I did not try to unmark is part of? (did not go back)
Thanks for any insights!