Discussions

 View Only
Expand all | Collapse all

Get the role of a user in a user field

  • 1.  Get the role of a user in a user field

    Posted 23 days ago

    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
    ------------------------------


  • 2.  RE: Get the role of a user in a user field

    Posted 23 days ago

    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
    ------------------------------



  • 3.  RE: Get the role of a user in a user field

    Posted 22 days ago

    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
    ------------------------------



  • 4.  RE: Get the role of a user in a user field

    Posted 22 days ago

    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
    ------------------------------



  • 5.  RE: Get the role of a user in a user field

    Posted 21 days ago

    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
    ------------------------------



  • 6.  RE: Get the role of a user in a user field

    Posted 21 days ago

    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
    ------------------------------



  • 7.  RE: Get the role of a user in a user field

    Posted 21 days ago

    That is what I had started but I'm not sure how to complete the Make Request part.  I have been able to pull all of the user info using api_user roles via a full url but not sure how to do that via the make request and only get the role of the user in the created record.  Any ideas?



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 8.  RE: Get the role of a user in a user field

    Posted 21 days ago

    The request would end up looking something like this: 

    You would swap out the actual user that you were intended to look for from the record being updated. 



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



  • 9.  RE: Get the role of a user in a user field

    Posted 21 days ago

    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
    ------------------------------



  • 10.  RE: Get the role of a user in a user field

    Posted 21 days ago

    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
    ------------------------------



  • 11.  RE: Get the role of a user in a user field

    Posted 21 days ago

    Yes, that is exactly what I'm wanting to do.  I'm getting an error, this field contains invalid jinga references.  {{b.json.qdbapi.user.roles.role.name}}



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 12.  RE: Get the role of a user in a user field

    Posted 21 days ago

    Can you screenshot or download the yaml to post here to look at? The jinja I provided is based on the key path for a single role in my example and works for me - you should be able to confirm by looking at the activity log and specifically under the request to get the role you should get something like this in the log: 



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



  • 13.  RE: Get the role of a user in a user field

    Posted 21 days ago

    I'm attaching.  It does bring back the user id and name, I just remove them due to privacy.



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 14.  RE: Get the role of a user in a user field

    Posted 21 days ago

    I also tried this.  I get the same error. {{b.json.qdbapi.user.roles.role.access.name}}



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 15.  RE: Get the role of a user in a user field

    Posted 21 days ago

    Here is also a screen shot of the update record action.  Just to make sure I'm not doing something wrong.



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 16.  RE: Get the role of a user in a user field
    Best Answer

    Posted 21 days 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.  RE: Get the role of a user in a user field

    Posted 21 days ago

    Yes it did.  Thank you so much for your time. I've learned some things today.  



    ------------------------------
    Carol Mcconnell
    ------------------------------



  • 18.  RE: Get the role of a user in a user field

    Posted 21 days ago

    I think this is the full image you wanted.



    ------------------------------
    Carol Mcconnell
    ------------------------------