Variable and Server Conect

Hallo Wappler Team
I made a Server Connect lg_select with colums from the Database lg_de and lg_fr and a Variable lg for change the content from de to fr.
Now i like to mix the Server Connect with the Variable
{{lg_select.data.language[0].lg_(here i ned the part from the Variable lg)}}
Is that possible?

Hi.
I don’t think using variable names dynamically is possible.
You could use ternary operator for binding variables conditionally.
For eg:
lg_de.value == '1' ? lg_select.data.language[0].lg_de : lg_select.data.language[0].lg_fr

@nshkrsh has given you a good answer which may be solve your problem. However, particularly if you have multiple languages, an alternative approach may be worth considering (though using nested ternary operators would be on an option in this case - but the code could become rather inefficient).

I had a similar need for dynamic content and @George produced a new formatter (which I imagine will be incorporated into Wappler at some point - it would certainly be a useful feature). It’s discussed in this thread.

1 Like

Thanks. Thats perfect for tis situation. But now i have another Question. Sometimes i need tis Part withoute : (else). Something like this: lg_de.value == ‘1’ ? lg_select.data.language[0].lg_de.

Try null or '' for the else part.
Eg: lg_de.value == ‘1’ ? lg_select.data.language[0].lg_de : ''

Thanks, that,s a good solution.

Hi
I have an other Question and i’m shure you have a good solution for me.
We have this 3 different situations to show some contents:
dmx-show=“repeat_query_2A.sum(mes_ver)>0”
dmx-show=“repeat_query_2A.sum(mes_ver)==0”
dmx-show=“repeat_query_2A.sum(mes_ver)<0”
mes_ver is from the database and its a number field.
Now we need an other solution wehn the number field is [null].
Du you now this Problem? Thanks.

I’m not sure I understand the question here.

If the field is null, SUM will probably be null too. You can try this:
dmx-show=“repeat_query_2A.sum(mes_ver) == null”

1 Like

Perfect, that’s it. Thanks for this fast answer. You are the best …

1 Like