I am struggling to create a condition/behavior on an Add action that will only allow adding when there are no existing related items. I have two datasets, Dataload (r) and Inputs (r/w) that connect with a key. I am replacing Dataload with fresh data regularly and Inputs keeps track of comments/actions. I need 0 or 1 row in Inputs for records in Dataload.
Here is a situation where there is already one referenced row on the Inputs dataset and I thus don't want this Add action to appear:
And here is a case that has no referenced comments added yet, so in this case it's fine that an Add action appears:
On the + Add action I tried a condition but this does not work:
To ensure the "Add" action appears only when there are no existing related items in the Inputs table, you need to configure a conditional expression in the actionโs behavior settings. Start by verifying that the relationship between the Dataload and Inputs tables is correctly set up with a reference column. Then, go to Behavior > Actions and select the "Add" action for the Inputs table. In the Only if this condition is true field, enter the following expression:
COUNT(SELECT(Inputs[Key], [RelatedDataloadKey] = [_THISROW].[Key])) = 0
This expression counts the number of records in the Inputs table where the related key matches the current recordโs key. The action will only appear if the count is zero, meaning there are no related items. Save your changes and test the application to ensure the "Add" button only shows when there are no existing related items. This setup helps maintain data integrity by preventing multiple related items for a single Dataload record.
Thanks for the idea @mohssin365. The Inputs key is named Id and is set to type Ref. The Dataload key is also named Id. It did not do the trick unfortunately...
COUNT(SELECT(inputs[Id], [Id] = [_THISROW].[Id])) = 0
User | Count |
---|---|
18 | |
11 | |
11 | |
8 | |
4 |