Key column is not being populated

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:

TimestampNameDeviceIDPlace

I have setup a data source for this spreadsheet in AppSheet like this:

NAMETYPEKEY?LABEL?SHOW?EDITABLE?REQUIRE?INITIAL VALUE
_RowNumberNumber      
TimestampDateTime   XX=NOW()
NameText XXXX 
DeviceIDTextX XXX=CONTEXT("device")
PlaceText      

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:

vramdal_0-1695825394145.png

 

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?

0 3 73
3 REPLIES 3

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 ๐Ÿ™‚

Top Labels in this Space