Sending Multiple Selected Options within Dropdown to Datablaze

Hi TB Community,

With the snippet below- is there a way to "format" the results that are sent to a Datablaze table?

Currently - this is how two selection results are sent:
image

Would there be a way to get rid of the brackets + parentheses + comma and add "and/or" in between the two selections?

Property Strategy: {formmenu: default=; Section 8; Turnkey; Flip/BRRRR; Fixer Upper; name=propertystrategy; multiple=yes}

Hi,

The easiest way to do that is to create a second variable which is formatted and save that one instead of the original. For you case you would use the join function to convert the list into a nicely formatted string.

Here's an example:

Property Strategy: {formmenu: default=; Section 8; Turnkey; Flip/BRRRR; Fixer Upper; name=propertystrategy; multiple=yes}

{note}
{formattedpropertystrategy=join(propertystrategy, "BLAZE_AND")}
Formatted Property Strategy: {=formattedpropertystrategy}
You would save this second variable to Data Blaze instead of the original.
{endnote}

Alternatively, may want to use a Multiple Select field type in Data Blaze for this type of Data. That would display your data as separate chips in Data Blaze:

image

If you used that field type, you wouldn't change how you were saving the values as the Multiple Select field type needs values in the original format.

Hope this helps!

1 Like

I'm trying the same thing, but it looks like the datablaze multiple select field type need prepopulated options to allow the list values to be displayed as chip. Otherwise the field is empty.

In my use case, a snippet read column "Name" from table A , show a menu to select 1 or more of the values in table A . Then insert that result in column "User" in table B . "User" column need to be displayed as multiple select.

Here I have a multiple dropdown with 3 values

If the coresponding datablaze column only have 2 options, Choice C is ignored and not added as a new option:

Hello @cdagenais, I'll check internally if this intended behavior or something we want to address.

I can confirm that this behavior is expected @cdagenais. You need to make sure all the options are available when updating them via a Text Blaze snippet. This is done to avoid the potential issue of selecting invalid values, since the field can only contain approved values.

If you wish to set any possible value, this can be done using other fields such as the Text Field.

as the multiple select options I want to use are stored in another table, I managed to get the intended behaviour with the Link to table column type and passing the row id to dept->id as explained here Data Blaze | BSQL Reference

Only thing now is that if I use the datablaze select field , i get the id displayed in the form that I would like to hide.


Good to hear you found a solution!

There is no way to hide the IDs when selecting the value using the DB select menu, but a workaround is to get all the values from Data Blaze as a list, and then show only the names using a {formmenu} from the data you received.

Something like the below, where the "name" in x["name"] is the column name where your name is.

{dbselect: SELECT Type, Vial # FROM Open Nutrient Vials; space=0MSsJcbWTzhtX6WDaGm5KD; menu=no; name=form; multiple=yes}
{formmenu: values={=map(form, (x) -> x["name"])}; name=value}
{selectedValue=find(form, x -> x.type = value)}
{=selectedvalue}

1 Like

Thanks , I was struggling a bit when using that with a multiple choice formmenu but I succed with this (if it can help anyone else):

{dbselect: SELECT Name AS event_type, rowid() AS event_id FROM Type evenement; space=; multiple=yes; menu=no; name=Events}

{formmenu: values={=map(Events, (x) -> x["event_type"])}; name=Evenement; multiple=yes}

{selectedvalueID=map(evenement, (x) -> find(Events, y -> y.event_type = x).event_id)}

and inserting in datablaze with SET Event->id=@selectedvalueID
{dbinsert: INSERT INTO Example SET Event->id=@selectedvalueID; space=}

1 Like