Hi guys, is there a way to only “trigger a custom event when data changes” for a number field, when the change is postive.
I have users with Coins, when they earn Coins there is a notification. But they can also spend coins, thats why when the field is changing in both “-” and “+” value currently the notification is triggered, but it should only trigger when “+” is added.
(I cannot use backend workflows because I need to show an alert message element).
Hi there, @bubble48… there might be a better way to do this, but I made an example that does what you described by adding a custom state into the mix. When the page is loaded, I set a custom state (number) to the current user’s coin balance. Then, I added a condition on the action within the custom event (not on the Trigger a custom event when data changes action itself) to show the notification only when the user’s new coin balance is greater than the custom state’s value. Make sense?
As I mentioned, I have a working example, so if you need some screenshots to make things clearer, just let me know.
The example is pretty simple. I have a coins (number) field on the User data type, and I added a custom state (number) called current coins balance to the index page.
Again, being a simple example, I am doing everything through a Page is loaded workflow event. When the page is loaded, I set the custom state’s value to the Current user's coins. Then, I use the Trigger a custom event when data changes action to call the custom event that shows the notification when a user’s coins balance is increased. Finally, I make changes to the current user and increase their coins balance by 10.