Discussions

Expand all | Collapse all

How do I restrict a user to only add 1 child record to a given parent record

  • 1.  How do I restrict a user to only add 1 child record to a given parent record

    Posted 04-10-2019 21:07
    We have a master table "Feedback Requests" and users can add a child record "Reply" to each request for feedback.  I'm trying to limit the user to only 1 reply per feedback request.  In other words, if they've already replied I want to disallow them from adding a second reply.   Any ideas or solutions?


  • 2.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Posted 04-10-2019 21:15
    Somewhat surprisingly this worked as a formula text field set to be unique.  I suggest that you name your field

    [Sorry, but only 1 feedback per request!]

    You will see why I suggest that when you attempt to save the second feedback.


    List("-", ToText([Record Owner]) & ToText([Related Request])


  • 3.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Silver
    Contributor
    Posted 04-10-2019 21:28
    After some interesting testing; I love the simplicity of this.  This does assume that the same person will be adding a Reply though.


  • 4.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Posted 04-10-2019 21:34
    I presume that this was some kind of employee survey and they only want 1 reply per user per Feedback Request.  I was surprised it worked because one would think, the system does not know the Record Owner,  until after the record is saved.  But it must have looked ahead to see that ahead of the save.

    Well live and learn, that's why we haunt the forum,


  • 5.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Silver
    Contributor
    Posted 04-10-2019 21:40
    Out of all my suggestions, I thought that using 1 and 6 or 9 would be sufficient for managing it; however the user would never know that their reply was being deleted (and ignored).


  • 6.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Silver
    Contributor
    Posted 04-10-2019 21:32
    These solutions to cover various options and you will need a combination of them depending on how you are setting up access to your tables for the roles.  These methods would be necessary if the Reply user was not going to be the same person, necessarily.

    1.  Build a summary field between Feedback < Replies to count the # of Reply records.  Then update your [Add a Reply] formula to hide when the [# of Replies] >=1 (essential)

    2.  Hide your Replies table from the Users so they can only access the Replies through a Feedback record. (optional if you deploy 6 or 9)

    3.  Turn on (off) the [Hide Add Button/Links] at the Role Level to the Replies table so the Users cannot try to add Replies via the + sign on the purple bar (optional if you deploy 6 or 9)

    4.  Build a record picker that only lists Feedback with no replies so that if a user does try to add a record to the Replies table; they cannot select the Feedback record because it will not be listed (optional)

    5.  Turn off the ability to Grid Edit the Replies table; so they cannot try to create records via grid edit

    6.  Write an automation to delete any replies which are created when saved and the [# of replies] >= 2

    7.  Turn off the Users ability to edit Replies

    8.  Prevent users from copying-replies to create additional ones by turning off the view icon in the embedded report

    9.  Summarize the MIN record ID# of the Replies to a Feedback; then add a lookup field of the MIN Record ID# to the Replies.  Use a checkbox to identify Replies which are not "original" replies; and use a scheduled-automation to delete records where the [Checkbox] field is true.




  • 7.  RE: How do I restrict a user to only add 1 child record to a given parent record

    Posted 04-11-2019 01:37
    Thanks all... like many Quick Base problems, as soon as I wrote the post I figured out my solution.  Here's what I did:

    On the master table I created a summary field called "# of replies by this user" which totals the number of child records that match the criteria "posted by  = the current user" ('posted by' is a user field on the child record. 

    Then I added an if statement to the Add Reply formula URL field:

    If([# of replies by this user] > 0,"", URLRoot() etc...)

    This hides the button if the user has already added 1 reply.  I also set the role permissions to hide the Add buttons for that table. So without any button to add a record once the've added a reply... voila, one reply only.

    I know this isn't API foolproof, but we're only using the UI to add records.