Hello guys, have anyone of you already tried to match a response API object to an Option Set Type and succeeded ?
I want to match categories of items to my list of categories (as option set).
Example : API response " category : ‘CAT1’ " initialized as type Category (option set type).
My option set Category has 5 entries from CAT1 to CAT5 (named in their “display” attribute). Unfortunately , when calling the request I always get an empty value on this object, so I assume Bubble doesn’t manage to match the response to an entry in my option set.
So, is it even possible to do so , and if it is, what am I doing wrong ?
Did you find a solution to your problem?
Unfortunately I didn’t … I guess the only solution at the moment is by using the database for that kind of data.
Got it thank you for your answer.
Hey @arthur.kieffer , I’m not sure if this is what you need but I stumbled upon this thread and thought I’d try to help.
Is it possible to have your options exist in the DB and as an option set? That way your API call can match the DB but you can filter by options in the UI? I read/watched this thread last night and it details how to do that.
Let me know if that’s helpful or if I’ve misunderstood your question.
I had an API that returns a numeric value for ‘Role Number’, with say 13 = Manager, 22 = Clerk etc. I defined these as an Option Set type OSRole with Display attribute Manager, Clerk etc. and an additional attribute Role Number defined so that I have
OSRole - Type:
Role Number: number
OSRole - Data
Display: Manager, Role Number: 13
Display: Clerk, Role Number: 22
My API response includes the Role Number, and I want to convert that in a Workflow into an element within the OSRole type.
To do this I used:
(assuming API response is in a state ‘API Response’)
Custom State: API Role (with type OSRole)
Value: All OSRole:filtered:first item
The List Filter has a single constraint,
This OSRole’s Role Number is API Response’s Role Number
If the API Response’s Role Number doesn’t match an element within the OSRole option set, the result will be empty.
To get ‘All OSRole’, in the Value field select ‘Get an option’, select your Option Set and choose All options. This returns a list of all elements in the Option Set. You then filter that list with a constraint that matches only on the Role Number attribute, ideally that should return a list with a single element, and you convert that into an OS element by picking the first element in that list.
Hope this helps.