Forum Discussion

Stephony_DBH_'s avatar
Stephony_DBH_
Qrew Cadet
9 years ago

Is there a way to hide a drop down option based on the user?

I have a mutli-choice drop down with Item A, Item B, Item C. I would like to hide Item C for people who are in a particular role. Is this possible? 
  • A third approach would be to use Javascript. This is the most powerful and flexible way to do it, but it takes some technical know-how. If you use Dan Diebolt's Image Onload technique to load a Javascript file whenever your form is opened, you can use simple jQuery to remove options easily based on user roles.

    You can find out all the app's roles and the way they're represented numerically by looking at the source HTML of any QuickBase form. Search for roleinfo. The roles the current user is assigned to are held in a global variable called gReqUserRoleIDs.

    Let's imagine you want to remove Item C from the dropdown for Field ID# 6 for anyone in the Assistant role. You learn from the HTML of a form that the Assistant role has a numerical value of 20. Write a few lines of Javascript like the following and save it as a code page:
    (function() {
        // check to see if the current user is in the Assistant role, number 20
        if (gReqUserRoleIDs.search("20") !== -1) { // string.search() returns -1 if the search term isn't found, meaning, in this case, that the user is in role 20
             $("select#_fid_6 option:contains('Item C')").remove();
        }
    })();
    Next, create a formula text field that will get a Javascript file using the Image Onload technique (if you're not familiar with this, just do a search for it). Add the field to your form, and Bob's your uncle. If a user opens the form who has role 20, Item C will be removed from the dropdown for Field ID# 6.
    • GauravSharma3's avatar
      GauravSharma3
      Qrew Commander
      Hi Phillip,

      Thank you for sharing this here. I will try this in one of my scenarios. :)

      Thanks,
      Gaurav
    • nitinbisht's avatar
      nitinbisht
      Qrew Member
      Hi,

      i have a relationship with Two table and i want to automatically select parent record on drop down in child form, can it be done if yes please help me with this.

      ------------------------------
      nitin bisht
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        @ nitin I suggest that you post a new question and explain what value you would like to Auto Populate.

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        markshnier2@gmail.com
        ------------------------------
  • Not within a standard multiple-choice drop down.  However; if you created a table of those options you could then permission roles based on records meeting a criteria; so their "drop down" selections would be restricted to the ones you want them to see.

    You would create a table-to-table relationship between your "option list" and your main table to make selections.  Consider making the key field of that table the name, unless it's possible for those options to change name values.
  • A low tech option is to have a form rule
    When multiple conditions are true
    User is in the role particular
    Choice is C

    Action:
    Change choice to blank

    uncheck that checkbox at the bottom so that the rule always fires.

    So its not hidden but the user won't be able to choose it and have it stick.