Conditional actions in App Connect

When using conditional actions, is using the ternary operator the only option?

Eg: a modal with a form is displayed to edit to a record. There are two buttons: one to save; the other to save and then close the modal. Both buttons submit the form and then reload the data. Only one of them closes the modal. After some experimenting I came up with this:
dmx-on:success="{{update_closedialog.value?data_detail1.mdl_update_record.hide():’’;sc_fairs_list.load({})}}"

I don’t need the ternary operator - if the test fails (if the variable has no value), I don’t need the second result, so I’ve used ‘’. This works, but it doesn’t seem ideal. It would be neater to use an ‘if’ statement, but I couldn’t get this to work. Can other methods be used in such cases - eg using if, else, or switch statements?

There are many cases where I might need to hand conditions like this and it would be helpful to know if there are different methods available.

3 Likes

I too use empty single quotes for such conditions. I don’t think there will be a better solution until Wappler integrates conditions officially.

Thanks @sid - it’s helpful to have this confirmed.

I certainly hope this feature will be integrated into Wappler at some point. A feature request was made for this but it was over a year ago. I wonder with such requests if they end being forgotten. Obviously there have been many new users in that time who probably wouldn’t have seen the topic. Also, as people discover more about Wappler, the usefulness of features like this become more apparent. Perhaps old feature requests should be automatically bumped from time to time.

I think having a dedicated feature and bug tracker would be more meaningful rather than relying just on forum posts here.
The Wappler Team could have the right to decide what gets added, and users will have some piece of mind that something will get added or resolved.

About this particular feature, conditionals are pretty tricky in my opinion to be designed in current visual picker’s UI.
I have put in huge nested conditions in some of my use cases, which would require a condition builder similar to the one we have in DB query.

1 Like

I agree about an alternative to the forum posts. I imagine something like this already exists internally, but it would be useful if we had some idea of what is contains, along the lines you suggest.

I’m sure you’re right too that it would not be easy to develop a more sophisticated action builder. I don’t supppose it’s a priority, or that it deserves to be at this stage, but eventually I think it’s something Wappler should have and is more deserving than the total of 3 votes suggest (IMO).

Thats probably because the post is too old given the pace of updates and posts in the community.
5 votes as of now. :sweat_smile:

It is 6 now. We use nested ternery in so many places. It’s need. Wappler should support natively instead of us handcoding it.

1 Like