Exporting list of things as formatted text

Good afternoon,

I’m looking for ideas/help on how to export a list of things as formatted text. In particular, I want to export specific fields of a list of things in to a paragraph for the purposes of sharing.

The scenario:

In my app, each user can have a number of “Collections”. Each of these Collections has a list of "Item"s. Each Item has fields for Name (text), required), Brand (text, required), and Variation (text, optional), as well as several other fields which aren’t really important other than to clarify that I don’t actually want to export the ENTIRE item.

A user may have a desire to share the collection. While they can share a link to the collection, suppose that the forum that they’re sharing the collection on has strict rules, and they need to be able to list the items in formatted text.

The problem

I want to be able to generate a text from a given Collection’s Item list. Assume a user has a Collection with the following Items:

[
{
Name: “Alpha”
Brand: “Acme”
},
{
Name: “Beta”
Brand: “Acme”
Variation: “V1.0”
},
{
Name: “Beta”
Brand: “Acme”
Variation: “V2.0”
},
{
Name: “Gamma”
Brand: “Bravo Corp.”
Variation: “Red”
}
]

The text should be formatted as such:

Acme Alpha
Acme Beta: V1.0 and V2.0
Bravo Corp. Gamma: Red

My attempts thus far

The closest I’ve been able to come so far is using a repeating group with the data source set to the list of products sorted by Brand, Name, and Variation and then having a text field on each which displays the data formatted. However, this has two issues.

  1. I can’t seem to access a cell’s contents from outside the repeating group, so I can’t concatenate the results together
  2. This approach doesn’t allow me to merge Items with the same Name and Brand together so that Variations can be formatted as above.

Any suggestions would be helpful. This is one of those cases where it would be trivial if I had the ability to directly manipulate the list programmatically, but alas I don’t.

You should be able to do this.
It’s probably not the most efficient, but I would imagine you could:

  1. add a text field in the row of a repeating group
  2. In that text field you can format how you want the information to be exported
  3. Outside of the repeating group, you can put another element that has as source Repeating Group's Text Element.
  4. you could do some further tweaking with find and replace.

That should list everything you need. There are plug-ins that allow you to save that to the user’s clipboard.

Thanks for the suggestion. Perhaps I’m missing something in your answer. I don’t seem to be able to access information from inside a repeating group’s cell from outside the repeating group. The only options I have for accessing data from the repeating group are “'s list of Products”, “is loading”, and custom states.

Yep, choose that and then new choices should appear.

When I select “Repeating Group Test’s List of Items” (I said List of Products earlier, but that was a typo), the only options I get are the standard options that I get from a list of Items, which I can get from the source of the repeatingroup directly. I can’t seem to access any of the elements within a repeating group, either per-cell or as a list.

Looking around other forum posts, I can’t find any way to access elements within a repeating group’s cell from outside the repeating group. I even found a comment from 2016 (granted, this is old) from emmanuel saying that it can’t be done.

Am I just missing something completely?

That’s exactly what you need. Here’s an example I just pulled together in one of my apps:

That element then will be populated with all the items:

I’m still unclear as to how this gets me any closer to the formatting I need.

I can do Repeating Group Test’s List of Items’ Brand, and this will give me

Acme, Acme, Acme, Bravo

Or I can do Repeating Group Test’s List of Items’ Name, and that will give me

Alpha, Beta, Beta, Gamma

But these would just be equivalent to obtaining the data directly from the source of repeating group. They would be the same as Page Test’s Collection’s Items’ Brand, or Page Test’s Collection’s Items’ Name (where Page Test’s Collection’s Items is the source of the repeatinggroup).

The problem I’m having is not obtaining individual lists as strings, but formatting multiple lists together into one list. As you can see in the formatting in my post above, the Name, Brand, and Variation of each Item are combined into one string.

Oh, I see. Apologies, I think you mentioned that from the onset and I thought this would be simple. I was trying to be helpful and I was too confident.

Here are the options I would cycle through:

  1. if that data merged & formatted is important, why not have a field for that?
  2. otherwise, I believe you can achieve that by manipulating states. One for each row and then one to aggregate all the rows
  3. Plug-ins. I’m thinking either the BDK’s RepeatingGroup Tools or @keith’s - aka America’s Most :heart:’d Bubbler™ - List Shifter.
2 Likes

Thank you so much! Keith’s fantastic plugin did just the trick, and actually may be useful for some other issues I was having. I didn’t even have to use a repeating group!

1 Like

Now I’m curious how you came up with your own solution.

Using Keith’s ListShift plugin, I set up a workflow that started an iteration on the list of Items (sorted by Brand, Name, and Variation). The iteration custom action was responsible for formatting the text correctly for each Item (and did so by calling other custom events, simply for organizational purposes).

Before starting the iteration, I set three states that are used by the iteration event to their default values (empty). The first is a text called “Iteration Item”, which represents the current string that is being formatted. The second is a list of texts called “Iteration List”, which stores all of the iteration items and is used to apply the final formatting. The third is a list of texts called “Last Brand/Name” which stored the most recent Brand in the first item and the most recent Name in the second item. This is basically a tuple if you’re familiar with them, and is the key to combining Items with the same Variation.

For each iteration, a check is made. If the Item is the same as the previous Item (it has the same Brand and Name as Last Brand/Name, then its Variation (if it has one) is appended to Iteration Item. Iteration List’s last item is then popped and replaced by the updated Variation Item.

If the item is NOT the same as the previous item, then Iteration Item is replaced by the Item’s Brand, Name, and Variation if it has one, formatted as above. Iteration Item is then appended to the end of Iteration List, and Last Brand/Name is updated with the current item’s Brand/Name.

At the end of the iteration, the final list is concatenated together using “Iteration List join with line_break”. Since the iterations are asynchronous, I had to accomplish this by added a check in the iteration to see if the current item is the last item in the list, and if so, do the final parsing.

Finally, it should be noted that states can only take 1 expression as a value, which makes text formatting difficult. In order to get around this, I used a trick I learned a while back in another forum post:

Create a multi-line input. This will allow you to easily format text, even with newlines (if needed). Copy the contents of the multiline input, and paste into an input with the content type set to text. Then, change the content type to “address”. This will cause the multiple expressions to be condensed into one, while still retaining formatting. You can then paste this into a state value. In order to modify state values, you can do the opposite by copying the state expression and pasting into an input with the content set to address.

1 Like

Wow, great! Thanks for sharing.

I think I read this, too. Was it in a list of unusual tips?

I’m not sure. I had an issue about a month ago relating to attempting to concatenate two strings, and I wanted to store them in state. I googled around and found a forum post (can’t remember much about it now) suggesting formatting it in an input and switching the content type to address. The multiline input part was something I figured out on my own that made it easier to format newlines.

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