Remove "Add" button when child record exists

I've seen lots of posts about this general issue, but none that apply directly to my need.  I'm new to Appsheet and need a bit of hand holding in this mid-level stuff. 

I have a parent table with a child table.  There will never be more than one child record for each parent record.  Once someone adds a child record associated with a parent record, I want to remove the "Add" button so they won't attempt to add another record.  

Parent table = "Jobs" with a rec ID of "Job Number"       

Child table="Chainsaw Detail" with rec ID of "Trees Job ID" that matches the Job Number in the parent table. 

What formula/function do I use to test to see if the record exists and where do I place that formula to make it all work. 

Thanks for any help you can lend!

Wick    

Solved Solved
0 6 365
1 ACCEPTED SOLUTION

Hey man,

no biggie.
The Action has to happen in the Parent Table. So best is to completely hide The "Add" Action in the Trees Table by selecting "Do not Display" under Prominence
Last, create a new Action in the Parent Table Jobs called "Add Tree" or "Add Child" as follows:

AddChild.png

View solution in original post

6 REPLIES 6

Hey man, 

it's simple. Just use this statement in the Add action behavior pane:
Only if this condition is true = ISBLANK([Related ChildRecords]) 
or 
COUNT([Related ChildRecords]) < 1

This looks like a brilliant solution!  It took me a while to see where you were referring to the action behavior pane - I had not used that before.  As a new developer, I am having trouble understanding exactly how I am to code the [Related ChildRecords] reference.  

Example: I'm assuming you mean to add a behavior test to the "Add" function for the child "Trees" table.  It's a child to the "Jobs" table.

wcksmith_0-1704369145167.png

What's the syntax for testing for the [Related ChildRecords] in that Trees table?  Thanks so much for your help.  This sounds like the perfect solution if I can get it coded correctly!

Hey,

in your Parent Table all the way at the bottom, there is a Virtual Column (Virtual Field) in your Table Layout that is called "Related Somethings" or whatever, that References your Child Records via (REF_ROWS). Just use that FieldName in your expression instead of [Related ChildRecords]

I hate to be a pain about this, and you've been very helpful, but I can't seem to get it to work.  The name of the field in the parent table called "Jobs" is "Related Trees". 

I tried [Related Trees] as the field name and it said it couldn't find that field.  I then used [Trees Job ID].[Related Trees] which it found - that was what the Expression Assistant inserted when I asked it to insert the code for that field from the parent table.  It accepted that OK.  However, it does not remove the Add button when a record exists.  I've synced the app and reloaded it in a browser and on an iPad and get the same results - no impact on the Add button.  Here's a screen shot of what I added:  

wcksmith_0-1704399316932.png

Again, any direction is greatly appreciated.  Thanks for putting up with me.  

Wick

Hey man,

no biggie.
The Action has to happen in the Parent Table. So best is to completely hide The "Add" Action in the Trees Table by selecting "Do not Display" under Prominence
Last, create a new Action in the Parent Table Jobs called "Add Tree" or "Add Child" as follows:

AddChild.png

Thanks for the clarifications.  This did work as you describe.  The results were not as I had expected, but that's OK.  The spots where the new link to "Add" are not in convenient locations based on the workflow of those that will use the form.  I played with all of that and made several selections to see where the new link could be placed.  None were as convenient for our users.  I'll just tell them to ignore the Add button when a record already exists.  Thanks so much for your patience and help! 

Top Labels in this Space