Creating a formatted text entry into a Datafield

I posted this as a comment on another thread, but I think it needs to be its own thread:

Here’s what I’m trying to do, and trying to avoid creating yet another Thing to facilitate this.

The general case is this:

Things of type A
Things of type B with fields QQ and WW and also a field of type A

Do a search of B where A matches, with a bunch of responses (more than one value of B for A)
return the results formatted as such:

{
“QQ from Result 1”:“WW from Result 1”,
“QQ from Result 2”:“WW from Result 2”,

}

And save that resulting text in a datafield for type A

It’s a puzzle to figure out how to do a search in Bubble and have it return a formatted result in the way above. Help?

Basically I’m building JSON snippets out of search result and formatting the results of that search, but I can’t seem to figure out how to make this whole thing work.

The :join with operator and your own typing is how you do this.

Like curly brace, quotation mark Search for blah:join with ‘ “, “‘ quotation mark curly brace

How does that work when you’re merging the results from different fields? because the Search only returns a single field to join on. You can only get a single field back from a search result.

How would you use :join to provide the above example? I can’t think of how to provide multiple fields back from a search and join them in a more complex manner than use a single , or quote.

I don’t see how to structure a query such that I get:

{
“field 1 from result 1”:“field 2 from result 1”,
“field 1 from result 2”:“field 2 from result 2”,

}

There’s no way to do this, with the :join you can only do “field 1 from result 1”, “field 1 from result 2”, …

Right?

Oh, I see. Have you tried either of the two JSON generator plugins for this? (Note: I’ve not used them, but they seem to be designed for what you’re attempting to do?)

First, the JSON Generator plugin does not support API Workflows, as per his comment:

" Json generator plugin (which is client-side so can’t be used in API workflows)"

Also they don’t support the nested formats or support use of arrays. Regardless you still need to supply them with data through lists, and it won’t work as above. I challenge anyone to make the above use case work!

Yeah, if you need to do this ENTIRELY in an API workflow, client-side plugins will not help you.

So, just to be clear, all you want to do is spit out key/value pairs sourced from two lists (key is list of QQs, value is list of WWs). Correct?

Hi Keith no that’s not correct. I have a list of items A, and a list of items B with fields QQ and WW and A. I need to spit out a list of all items B where item A is in B’s A field, and format the results of WW and QQ as output from that. So WW and QQ are both in the same record for B. Not separate list.

As far as I can tell, this basic scenario is not doable in Bubble.

Thing A
Fields X, Y, Z

Thing B
Field J of type A, QQ (text), WW (text).

Search for all B where J is A, and return all records formatted as follows:

{
“QQ result 1”: “WW result 1”,
“QQ result 2”, “WW result 2”,

}

This is not doable in Bubble without lots of hacky approaches to create temporary tables or fields and build things incrementally. This is a trivial thing to do with ordinary programming

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.