Forum Discussion

CarolMcconnell's avatar
CarolMcconnell
Qrew Captain
3 months ago
Solved

Get the role of a user in a user field

I know for years getting this information has been almost impossible.  I wanted to see if there has been any updates.

I need to be able to pull back the user role of a user listed in a user field. I do not give my users multiple roles so it will only be one.  Is there any way to do this now without having to create a new table to house the information?



------------------------------
Carol Mcconnell
------------------------------
  • ChayceDuncan's avatar
    ChayceDuncan
    3 months ago

    So I went and tried it myself - I got the same error you got but it allowed me to run and it operated/saved as intended. I'm not sure why it thinks there's an error - but try and turn it on and see if you're able to get it to work. 



    ------------------------------
    Chayce Duncan
    ------------------------------

17 Replies

  • Unfortunately no. You will have to sync the data into a new table through a Pipeline or other method that grabs the data through the QB API to capture it. 



    ------------------------------
    Chayce Duncan
    ------------------------------
    • CarolMcconnell's avatar
      CarolMcconnell
      Qrew Captain

      Thank you for that.  So if I do a pipeline, then I'm thinking the first trigger would be when a record is created and then I need to do the api that would get the user role of the person in the assigned to field of that record and then update that same record with the role, in the role field.  I have only used api once so far and not in a pipeline, so I have some questions.  Would the next event after the trigger be make request?  If so, do you have direction for me, for that step.  I looked at it, but because I'm limited on my knowledge of API, I was not sure how that step should be set up.  Thanks.



      ------------------------------
      Carol Mcconnell
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        I wouldn't recommend it that way, no. In this case you would want to sync the role information daily or on a set cadence and grab all of your users. Basically a daily refresh of each user in your app and their current role(s). You can then use table to table relationships based on the user field(s) you're targeting to look up the role. The reason for this is that you don't want to capture it when the record is created in all likelihood since the users role may change over time. 



        ------------------------------
        Chayce Duncan
        ------------------------------
    • CarolMcconnell's avatar
      CarolMcconnell
      Qrew Captain

      I actually do want to capture the role of the user at assignment and I don't want it to change if their role changes.



      ------------------------------
      Carol Mcconnell
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        If that's the case then, you would do it on triggered or by whatever event you want the user role captured to capture in your field. Since it's specific to one user - you can user API_GetUserRole to get it using the Quickbase Channel and the 'Request' Step to call out to the QB API. The Pipeline will convert the XML into a JSON object that you can grab the user role from. I'm not sure about your security - but if you have instances where a user is assigned more than 1 role in the app - you will need to make sure to test that situation. Pipelines will provide a slightly different structure in their conversion of the XML since there are multiple that you'll have to adjust for. 



        ------------------------------
        Chayce Duncan
        ------------------------------
    • CarolMcconnell's avatar
      CarolMcconnell
      Qrew Captain

      Okay, so this worked great and it did bring back the user role.  Thank you so much for that.

      So now I have  an update record step and have selected the updated record and the field that I want to update which is assigned to.  What do I put into the assigned to field to get it to update?



      ------------------------------
      Carol Mcconnell
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        I'm not sure I understand. Are you asking how you grab the role value to log back into Quickbase?

        If that's correct - then you need to target the right part of the JSON response and put that into your update record. So lets say your trigger is on the new record - then you look up the user and then you want to update the value of 'Assigned To Role' in the original record then you would just do a regular update record action, and in the input for Assigned To Role you would do something like; 

        {{b.json.qdbapi.user.roles.role.name}}

        Where b is the request step to get the role. The json.qdbapi.... is the key path structure to get the name of the role. 



        ------------------------------
        Chayce Duncan
        ------------------------------