I want the user to be able to save a name describing the user's device. So I found the CONTEXT("device") function call, which gives a unique ID for the user's device.
I have a spreadsheet with these columns:
Timestamp | Name | DeviceID | Place |
I have setup a data source for this spreadsheet in AppSheet like this:
NAME | TYPE | KEY? | LABEL? | SHOW? | EDITABLE? | REQUIRE? | INITIAL VALUE |
_RowNumber | Number | ||||||
Timestamp | DateTime | X | X | =NOW() | |||
Name | Text | X | X | X | X | ||
DeviceID | Text | X | X | X | X | =CONTEXT("device") | |
Place | Text |
I have created a view to let the user enter data into this table. The view type is "Form", and under View options, I have specified the Row key = CONTEXT("device"), so that the user should only edit this row, no other rows:
Or, it should let a user enter a new record. When the view renders, only the NAME field is displayed - which is as expected. I fill in a name, and click "Save".
This causes an error message to be displayed: Key field 'DeviceID' is required.
I thought this could be because CONTEXT("device") did not work as expected. But even if I set the initial value to a static string, say "aaa", the same error happens.
What am I doing wrong?
That's not what that "row key" setting is for. That setting is to choose which existing record to open up in the form view.
Right, so I would use the row key setting to allow a user to edit her name, not to enter a new record?
Disable the system action you are using to open your form and create a new one.
The type of action will be
App: go to another view within this app
Target
LINKTOROW(CONTEXT("device"),"MyNewFormView")
The result:If the user has not saved a record before then clicking the button will allow them to save a new record as expected.. If the user has already saved a record before then that record is opened in the form and what happens after that is up to you ๐
User | Count |
---|---|
35 | |
30 | |
30 | |
20 | |
18 |