Records limitation while being editable

Hi,

I have a few tables that needs to allow only one record per user (as I use a ref to these using a ANY function). But I want this record to remain editable.

I am using this expression as data validity for the limitation :
COUNT(Select(coefficient FG MO[_Rownumber],[Usermail]=UserEmail())) <1

The limitation is working properly. However, the record is not editable (message of invalid entry) as soon as the form is open. No save possibility.

I tried to fix it using :
COUNT(Select(coefficient FG MO[_Rownumber],[Usermail]=UserEmail())) <=1

Then the record become editable but it allow to create another one.

Any suggestion ?

You could use an expression in the table’s Are updates allowed? property to allow the user to add a row only if they don’t already have one, or to only modify their row if it already exists.

Hi Steve,

I understand the expression COUNT(Select(coefficient FG MO[_Rownumber],[Usermail]=UserEmail())) <1 is not appropriate for what I want to do and your suggestion looks interesting. Any chance to get a clue about the way to write this expression ? I don’t get it as soon as multiple condition are necessary in the same expression.

In the app editor, go to the table’s configuration, find the Are updates allowed? property, and click on the flask icon:

After clicking the flask icon, click in the expression bar to open Expression Assistant:

From Expression Assistant, remove any expression already present and replace it with this:

IF(
  IN(UserEmail(), coefficient FG MO[Usermail]),
  "UPDATES_ONLY",
  "ADDS_ONLY"
)

This says if the current user (identified by UserEmail()) already has a row in the coefficient FG MO table, only allow that user to read and update (edit) rows of the table; otherwise (if the user doesn’t have a row), only allow the user to read rows and add a row.

Thanks Steve Working great !

1 Like