Ability to add conditions with appconnect action events

if we can mix conditions and actions in app connect that will make wappler on the same level as the top end visual web app creators today, for example something like this:

on the Dynamic Event for serverconnect form
if var==true
got to location
display notification

I believe it could already work with App Connect, like {{ var == true ? browser.goto(url) : notifies.danger('My Error') }}. This is currently not possible with the UI in Wappler and you also can’t use the actions as parameters in formatters like {{ (var == true).then(browser.goto(url)) }}.

I will try that thanks @patrick
at least if we have some documentation for App connect on this matter it will be wonderful
i don’t mind not using the UI for complex stuff.

I dont know if we are talking about the same thing but I think yes.

-I have a ServerConnect action that returns a value based on some conditions.

-In the AppConnect on the success event (it is a form that executes the ServerConnect action) I want to do different stuff based on the value that I get (for example open a modal or goto another url).

Any ideas on how to achieve this?

Thank you

sure you can. use what patrick suggested. it worked with me.
instead of var use your value returned from the server connect and then do the conditional part.

1 Like

I tried but truth is that I did not manage to make it work. SInce you verify it is working I will give a few more tries. Thank you!

1 Like

Did you make the check inside the success event when submitted the form?

i have it in the done event

{{ var1.value == true ? browser1.goto(url.value) : var1.value == false }}

var1 is app connect variable that i switch to off if its value is not true. and go to url if its true.

can you past your code here?

1 Like

dmx-on:success="{{ session1.data.loggedin==0 ? alert(‘ok’) : alert(‘no’) }}" also tried without the {{}}

do you see errors in the console? have you confirmed that the session1.data.loggedin have value?

Please try:

dmx-on:success="alert(session1.data.loggedin==0 ? 'ok' : 'no' )"

im pretty sure the alert is for testing purposes only.

It does nothing. Server action does execute but I dont get an alert or error.

Just found an alternative to make the check. Thank you very much @mrbdrm and @Teodor. I will, for sure, come back to this topic with some new tests.


i am 100% sure you will need this in the future :slightly_smiling_face:

1 Like

Sorry I missed the browser1 in my code:
dmx-on:success="browser1.alert(session1.data.loggedin==0 ? 'ok' : 'no' )"

Where browser1 is the name of the browser component on the page.

Yes me too. It brings up so many possibilities

Thank you @Teodor , I will check it and let you know.

I am very close to this but having an issue check below
{{get_items_in_cart.data.totalCost[0].temp_cart_quantity==0 ? browser_empty_cart.goto('index.php') : console.log('')}}

The issue is that if ‘get_items_in_cart.data.totalCost[0].temp_cart_quantity’ has no value it just disappears, I mean I can not compare it, it does not exist. How can I check this? If for example I use this

{{get_items_in_cart.data.totalCost[0].temp_cart_quantity==1 ? browser_empty_cart.goto('index.php') : console.log('')}}

when quanity ==1, it works. How can I check when it is =0, since there is no quantity the get_items_in_cart.data.totalCost[0].temp_cart_quantity becomes empty, not 0.

I also tried get_items_in_cart.data.totalCost[0].temp_cart_quantity==false or get_items_in_cart.data.totalCost[0].temp_cart_quantity!= true , with no luck.

Thank you

Try with:
{{get_items_in_cart.data.totalCost[0].temp_cart_quantity && get_items_in_cart.data.totalCost[0].temp_cart_quantity==0 ? browser_empty_cart.goto('index.php') : console.log('')}}

Or what exactly the condition you are trying to achieve is?
Do you at any moment set the value of the get_items_in_cart.data.totalCost[0].temp_cart_quantity to 0? Or do you want to check if any values are returned at all?
Please explain the conditions you need to check.