Forum Discussion
Is it still working when you have a single user role? My suggestion would be to change up how you're trying to evaluate if its a single or multi use case by checking if the data type is a mapping. So in the case of someone who only has 1 role if you do the following:
{{b.json.qdbapi.user.roles.role is mapping}} will return TRUE because the format is a mapping object
Where as the same check for a user with multiple roles will return FALSE because the data type is a List
------------------------------
Chayce Duncan
------------------------------
Hey Chayce,
Good to talk to you again. So I was able to find a work-around for this, but I'm down another rabbit hole with a similar issue that may be easier since you use and are familiar with this API.
Firstly, so that I can help anyone down the road, here is the code to loop through the role id in the case there are multiple:
{% set roles = b.json.qdbapi.user.roles.role %}
{% set separator = "; " %}
{% for role in roles %}
{{ role['@id'] }}
{% if not loop.last %}{{ separator }}{% endif %}
{% endfor %}
This creates a wonky output, but I fixed that by adding a formula - multi-select text field with a formula of:
Split([Role ID (Generated by Pipelines)], ";")
Now I can easily see both Role ID's. This works for the role names as well, and keeps them in the same order as the ID's as long as you don't have a ';' within the role name of course.
Now for my hopefully easier issue. Are you familiar with how to pull the access name and access id from the api response?
------------------------------
Shane Miller
------------------------------