Allow adds to table based on number of rows

I would like to only allow one row in a table of subrecords, but allow an existing row to be editable.  Basically, something like this in the Are Updates Allowed? field, but without the hardcoding:

IF(COUNT((Item Subrecord[LUD], ([Customer Id] = "938f7e3d"))) = 0,
     "ADDS_ONLY",
     "UPDATES_AND_DELETES"
)

Any suggestions on how to do this?  I tried using REF_ROWS() but it said Unable to find column '_THISROW.

In case you are wondering why I am doing this, it is a workaround to not being able to create a new subrecord in a form if no subrecord exists vs edit the existing subrecord if it does.

Thanks

Solved Solved
0 3 101
1 ACCEPTED SOLUTION

I actually solved this by having a "new" action which shows up when the following count is zero, and an "edit" action, which shows up when it is one:

COUNT(SELECT(Item Subrecord[LUD], ([Customer Id] = [_THISROW].[Customer Id])))

The "new" action has this target:

LINKTOFORM("Item Subrecord_Form", "Customer Id", [Customer Id])

And the "edit" subrecord has this target:

LINKTOROW([Customer Id], "Item Subrecord_Form")

View solution in original post

3 REPLIES 3
Top Labels in this Space