Discussions

Expand all | Collapse all

Create a Role using QB API's

  • 1.  Create a Role using QB API's

    Posted 17 days ago
    Hey guys!

    I am trying to create a role automatically whenever a new record is added to a table.
    Sadly, and for some reason, this is the only thing that the QB APIs doesn't have access to.
    Does anyone know of a way to do this? Or will I have to manually create the roles for each record?

    Any responses are welcome, thank you!

    ------------------------------
    - Sterling Long!
    ------------------------------


  • 2.  RE: Create a Role using QB API's

    Posted 17 days ago
    I will make you a deal. If you promise not to make an app with so many roles, I will promise to find a solution that does not need to have many roles. 

    Can you describe why why you feel you need so many roles?

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 3.  RE: Create a Role using QB API's

    Posted 17 days ago
    We are making an app that we will be selling as a service to multiple companies. Each company has access to only their information, and we have a system set up that will filter out information that isn't there based on the role that they were given.
    Essentially we need some way to filter their information so they only see their information and no one elses.

    For each company there will be two types of people, and possibly others in the future: Admin and Normal.
    The best way we have thought to do this is with roles, and what we have works, we just have to make each role manually, which takes time and is prone to errors, which is why I wanted to use an API to make it happen automatically.

    What are your thoughts? This is the only way we could think of to silo the information in the way we needed.

    ------------------------------
    Sterling Long
    ------------------------------



  • 4.  RE: Create a Role using QB API's

    Posted 17 days ago
    That is what I suspected. But when i get a chance I will honor my promise.  If you promise not to do a brute force solution with a zillion Roles,  I will post back with how to do this with 1 Role. .. later today.   Gotta run to meetings now.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 5.  RE: Create a Role using QB API's

    Posted 17 days ago
    So my first thought when I found that I could not create a role using the api was to possibly have two fields for each company that we bring on, and use whether or not they were in a specified field to filter the information.
    This does not however give us the ability to have both admin and normal rights for those users, as far as I know.
    Company admins will need to be able to add additional users to their company as they see fit, and promote them to admin if they desire. Normal company users should not be able to add other users. It is possible as well that we will end up adding additional roles, like view only as a lite user? Not sure.

    Any flexibility or direction you can give us would be appreciated. Thank you!

    - Sterling Long!




  • 6.  RE: Create a Role using QB API's

    Posted 17 days ago
    Sterling,

    Please follow up with Mark.   You do NOT want those Roles! 

    His solution will be much more elegant and easier for you to maintain.


    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------



  • 7.  RE: Create a Role using QB API's

    Posted 17 days ago
    OK, here's the setup.

    Create a table of Users where the Key field is userid.  Let's call the table Users Limited By Company.
    Create relationship where One Company has many Users. Great, now each userid knows the Company they need to be limited to.

    Here is the magic. 

    Create a relationship where 1 Userid in that table has Many "records".  If there are multiple tables which need to be limited you will need to do this for each table.  Let's say the table being Limited is "Orders".  OK so One User has many Orders.   Change the reference field on the right side of the relationship  from being called Related User to be called [Current User] .  Of course you know that just calling a field [Current User] don't make it actually be [Current User] so we change this to a formula user field with the formula of 

    User()

    That function returns the current user.

    That's the very kernel of the magic that only Quick Base can do.  So now look up Company from that relationship down to Orders, ie that will be the Company for the hands on keyboard current user,.

    Make a formula checkbox field called [User allowed to see this company?]

    IF([Company] = [Current User Company], true)

    Now set up just 1 Role for regular users limited by company and set the Custom rules to only be able to see Orders where [User allowed to see this company?] is checked.

    If you need a higher level Role with Share permissions, then go ahead  and duplicate that Role but use the same type of Customer Rule to limit access.  Note also that if you need that field on any child records of orders, say Order Line, you can just look up that fiel form the parent and make a similar Customer Permission Rule

    Voila, one role (except you need  two due to different Share permissions.



    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 8.  RE: Create a Role using QB API's

    Posted 16 days ago
    Ok so essentially construct the “roles” by checking current user and their related company, then make sure each record has a company field and make sure the company fields match using that formula? Did I follow that correctly?

    I will look into this some more later tonight. Thank you for the response!

    - Sterling Long




  • 9.  RE: Create a Role using QB API's

    Posted 16 days ago
    Yes, post back if you get stuck.  :)   It's a great technique.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------



  • 10.  RE: Create a Role using QB API's

    Posted 16 days ago
    So this seems to work, however, how would I hide the company information from users?

    For example, a user in company X should only be able to see company X in the Companies table. Pulling back up and using the role doesn't work because the comparison has to start somewhere... Not sure if that last part makes sense. 

    What would you recommend here?

    ------------------------------
    Sterling Long
    ------------------------------



  • 11.  RE: Create a Role using QB API's

    Posted 15 days ago
    Yes, you are correct that if you try to put Role permissions on the company table, it gets too circular for Quick Base and will break everything.

    There are a variety of solutions.

    One way is just to hide the company table from that role.

    Probably the best would be to set up a Sync table and then set Permissions to only allow those users to see companies in the Sync and then look up fields from the real Companies table to the Sync table.


    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    markshnier2@gmail.com
    ------------------------------