Forum Academy Marketplace Showcase Pricing Features

Set Custom State to Data Fields Value

I’m trying to build a coupon submission field.

I have a data type called “Coupon” with a data field called “coupon code” and another data field called “discount value” which contains the actual amount of the discount. I have an input field where the coupon code is entered. I want the input fields custom state to change to the coupons discount value when the input field’s value matches that coupons “coupon code”.

Here is what I have set up so far: Workflow where “When Input Field’s Value contains Search for Coupon’s Code:first item.”. When that condition is met, its custom state is changed to “Search for Coupon Discount:first item” and the condition is “Code = Input Field’s Value”.

It works for the first coupon I’ve created, but when I try the second coupon it doesn’t work. I suspect I’m messing something up wth the “First Item” calls. Any suggestions?

What you outline sounds reasonable. Can you build an example into the forum_app3 to help debug the problem?

Hmmm, I can’t seem to recreate the same result. Everything is set up as it is in my app.

Would you mind looking at page “Coupon Testing” ? When a valid coupon code is typed into the input field and the “Apply” button is clicked, the number 100 should be reduced by 30 (which is the discount value of the coupon).

Would really appreciate any help you;re able to provide.

Ok the forum_app3 is working just as my app is.

But it still won’t accept any other coupon codes.

Alright I figured out what the problem was…

I changed the order of the “when?” condition and that seemed to fix it. I changed the condition from “Input Field’s Value Search for Coupon’s Code:FirstItem” to “Search for Coupon’s Code contains Input Coupon Code’s value” .

In my mind, both phrases are saying the same thing, but apparently not.

Thanks for setting up the example. Yes the condition wording does look confusing.

There was a subtle bug, in the search part of the condition you forgot to constrain by the coupon code, so the first item returned depends on the list ordering or a random item in the list.

When the search is constrained, it will return a list of matching coupons or an empty list, so instead of comparing to the coupon code, I’d check if the list count is greater than zero.

I’d suggest moving the condition into the button click event:
“When Button Apply is clicked and when Input Coupon Code’s value is not empty and Search for Coupons:count > 0”
Then it can do the action of setting the state with the new total.

I’ve updated the example in:

I hope this helps!

1 Like