Forum Discussion
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
------------------------------
How you 'use' it will ultimately depend on how you're passing it into QB but the actual task of getting to the object itself is just a matter of continuing the JSON path through to the access object. So if in the case of a single user/role you would just have json.qdbapi.user.roles.role.access["@id"] and json.qdbapi.user.roles.role.access["#text"].
In the case of your loop you still do the same thing - just role.access["#text"] or role.access["@id"]
------------------------------
Chayce Duncan
------------------------------
- ShaneMiller17 months agoQrew Cadet
Awesome, that worked. It's so weird, I must have been at it too long because prior to trying to loop everything I had both the access id and access name fields populating. Then for the life of me I couldn't get it to work pre-looping. Probably a silly syntax error... 'name' instead of '#text'.
Either way, thank you! It's all working as expected now
------------------------------
Shane Miller
------------------------------