Forum Discussion

AndreonnaGarret's avatar
AndreonnaGarret
Qrew Assistant Captain
8 years ago

Only allow a specified user to click URL Button

I have a URL button for approval on a form. Above this I have a field where the user is picked. Is there a way to restrict access so that only the user specified can press this button? I have achieved this directly on the form using a form rule, but this button is also on reports that I would like to restrict the access as well. Additionally, if possible, can I restrict this button without making it hide from the form.

I have provided images. The button I am referring to is the "Employee Agrees" button. I would like only the user listed in the "Employee Name" field to be able to press this. I can achieve this through form rules, but the field still shows on any reports. I have this embedded on another table, so I need to be able to have this restriction there as well. 

Any help would be greatly appreciated!
  • You can set any field to View, Modify or None for each Role.  Access the field and scroll to the bottom of the field characteristics to set the Role Access Permissions by Role.  Set Roles you don't want to see the field to "None
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    If your [Employee Name] field is a User field, then you can do it by making the formula cantain an if that evaluates the current user:

    If([Employee Name]=User(), "My button formula for employee agrees goes here", "")

    That will show the button for only the user in the employee agrees section, otherwise it will be blank.
    • AndreonnaGarret's avatar
      AndreonnaGarret
      Qrew Assistant Captain
      Sorry, I am really quite new at formulas in QuickBase. How would I add this additional IF function to my current formula? The formula currently in the button is:

      var text url =
      If([Employee Agrees Check]=false,
        URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
          "&rid=" & [Record ID#] &
          "&apptoken=cp2kg3vbugcf22bd656gmp4udhs" &
          "&_fid_9=true");

      If([Employee Agrees Check]=false,
      "<a class=\"Vibrant Primary\" href=\"javascript:" & "$.get('" & $url &
          "', function(){" & "location.reload();" & "});" &
          "void(0);\">Employee Agrees</a>"
      )
    • MCFNeil's avatar
      MCFNeil
      Qrew Captain
      Put it before your second section.... with a slight change

      If([Employee Name]=User() AND [Employee Agrees Check]=false,
      "<a class=\"Vibrant Primary\" href=\"javascript:" & "$.get('" & $url &
          "', function(){" & "location.reload();" & "});" &
          "void(0);\">Employee Agrees</a>",
      ""
      )