[SOLVED] Use boolean to 'Search for' multiple results

I show the number of invoices which has a status of drafts, sent or paid. I get the info by doing a DB search.

1

I don’t want to show the text unless necessary, so if there are no drafts and no paid invoices, I want to show Invoices (2 sent) and have no mention of draft or paid invoices.

The only way I can think to do this is with a very complicated set of conditionals which say something like;

Search for invoices (drafts), if there are 0 then show this Text;
Search for invoices (sent), if there are more than 0 and Search for invoices (paid), if there are more than 0.

Search for invoices (paid), if there are 0 then show this Text;
Search for invoices (sent), if there are more than 0 and Search for invoices (drafts), if there are more than 0.

There are multiple variations and it get’s complex. Is there a cleaner way to do this? I would like to just say; if there are draft invoices then add that to the text sentence. If there are paid invoices then add that …

One easier way would be to just split the text in different text fields and each one has a condition to only show when count is not 0.

Thanks @michael.schmid for the suggestion but the text fields remain in their positions so if only one of the conditions is met you would have a strange space where the other two (empty text fields) would be. We can make groups hidden and collapsed but unfortunately they only collapse vertically, not horizontally, so I couldn’t even put three text boxes in groups and collapse the hidden ones.

**The issue seems to the be minimum width of the group set to a large number.

^As @michael.schmid suggested: Split the text in different fields. Check “Collapse when Hidden” in the layout options for the text elements if they are all in a single group, and check it for the individual groups if text elements reside in their own parent group.

Make sure to set the minimum width of the group (or groups) containing the text to around 50 and check “Fit width to content”.

@deejay.shani Thanks for your input. Here’s an example of why the above doesn’t work.

I have split the text in different text fields and each one has a condition to only show when count is not 0. The text fields must be inside a group in order to “Collapse when Hidden”.

In this example, the first condition is not met and it does successfully collapse, but collapsed groups collapse vertically so the other two text fields remain awkwardly set to the right, rather than shifting left. This is why I think I may need to put all text/conditions in one long text field.

2

Do you have any minimum width defined on the parent group or parent row?

Also, is this the old design engine or the new responsive engine?

Set this data on the group itself, then inside the group you can reference it, if the value is equal or less than 0, you hide it. or equal or more than 1, you show the text. Using this method allows you to reference it in multiple places within your app.

For the width, use fit to content on the new responsive engine.

No, there’s no minimum width on the parent group and I am using old design engine. I did try the new engine and found it very unintuitive, I definitely don’t want to switch!

Thank you for the idea, this would be a good idea but I don’t like the responsive engine at all. In fact, I emailed Bubble today to check that they won’t remove the old legacy engine because I prefer the old to the new!

You should like it, just try it around for two weeks. You wont go back to the old engine. (promised)

1 Like

I’d try something like the following:

  1. Get the list of non-zero count statuses (either in a state or some hidden RG).
  • Search for invoices: each item’s status: unique elements.
  1. Do a “format as text” on that list of statuses:
  • [result of step 1 above]‘s statuses: Formatted as text:
    – (search for invoices [status = this status]: count "this status’ Display")
    – Delimited with " " (space)

The result should be an accounting of the number of invoices with each status where each status is present at least once. There are definitely some things you could do to make the above more efficient, but that’s the basic structure I’d go for.

1 Like

You can format boolean values as text directly in the text box, so the simplest and most efficient way to to this is to write the conditional expressions directly in the text box, then use ‘Format as text’ to set the text value for Yes and No accordingly.

That way you don’t need any conditional formatting.

For example, in the text box write: Invoices search for invoices/status=draft: count > 0 that will give a yes/no output on which you can apply the Format as Text operator.

For Yes, the text can be: (search for invoices/status=draft: count drafts) (be sure to include a space at the end).

For No, just leave it blank (no spaces or anything).

Then add the same relevant expressions for the sent and paid invoices.

That way, if the count of the specific type of invoice is 0 nothing will be displayed. If it’s more than 0 it will be.

3 Likes

Thanks @nnich19 I think I understand, I will give it a go, I appreciate it mate. UPDATE: I’ve gone with @adamhholmes solution as it did the trick but thanks again for your suggestion.

As always, thanks so much for your advice @adamhholmes , I will try your solution as well, it seems very ‘lightweight’ which I like. Thanks for the clear screenshots, that makes such a difference.

UPDATE: This worked perfectly! Now I just need to figure out how to make the text box dynamically expandable so it stretches to fit the text. I know I can do this with the new responsive engine but I can’t face it at the moment!

With the old engine, you can use a custom class and add a CSS style to achieve that. See @fayewatson messenger/chat template.

Thanks @yusaney1 I think you are referring to dynamically expandable text boxes, I have replied to you over on the correct thread which is for that.