If your application needs to limit the number of records added by the user, you can solve this problem using the "Ajax Request" field.

Create this field for the entity where you want to set the constraint. In the "PHP code" option, write your request with conditions. For example, we need to make it so that each user can add only one record. Sample code:

//Count the number of records added by the user
$count_query = db_query("select count(*) as total from app_entity_22 where created_by=" . $app_user['id']);
$count = db_fetch_array($count_query);

if($count['total']>0 and $_GET['item_id']==0)
{
  //Hide form fields and display a message
  echo '<script>$(".form-body").html("<div class=\"alert alert-warning\">Вы уже добавили запрос!</div>")</script>';
  //Hide the "Save" button
  echo '<script>$(".btn-primary-modal-action").hide()</script>';
}

app_entity_22  - where 22 is the entity ID.

$app_user['id'] - current user ID.

$_GET['item_id'] - current item ID. (zero means New Record)

If you have a nested entity and the request needs to take into account the ID of the parent record, the request will look like this:

db_query("select count(*) as total from app_entity_22 where created_by=" . $app_user['id'] . " and parent_item_id=" . $_POST['parent_item_id']);

$_POST['parent_item_id'] - id of the parent record

If you need to take into account the current date, for example, a user can add only one record per day, add the following condition:

db_query("select count(*) as total from app_entity_22 where created_by=" . $app_user['id'] . " and FROM_UNIXTIME(date_added,'%Y-%m-%d')= FROM_UNIXTIME(" . time() . ",'%Y-%m-%d')");

Please note that since the "Ajax request" field is used only for calculations, we do not need to display it. We can hide this field on the Record Page Setup page.