If..Else.. not working properly for some reason


#1

I have an if… else… statement On Load of a dynamic list tile.

If Number Count > = 1 it’s supposed to show/hide some elements on the page.

image

For the life of me, I can’t figure out why it’s not working…

I also tried <1 and to hide/show things based on the response received inside of that list tile to no avail.

Some elements default to hidden… Some of the elements default to being shown on page load… My settings are all correct and I can’t figure out why it’s not working when my response is definitely “0” which is less than 1.

API RESPONSE:

image


#2

Hi @justincrabbe, a bit hard to keep track of what’s going on here because you’ve mentioned so many different combinations - few things to try / bear in mind:

  • It looks like the value coming back is an int so I’d use an int in your If Else - I’d still expect it to work with the float so I doubt this will fix the error but just in case.
  • If the If Else is on load of a list tile it should only be attempting to alter elements inside the list tile, not outside it, that typically won’t work because you’d be resetting it for each item in the array. If you need elements outside the list to update you would typically do that somewhere else outside the scope of the list e.g. the API request status code event.
  • What I normally do in situations like this is add an action before the If Else to e.g. show a toast or maybe update a text element with the field I’m testing (quote_count_number in your case), but bear in mind it’ll execute for every item in the list if you do it in tile load so it’s not really an ideal way to validate in this case.

It sounds to me like your logic maybe needs a rethink here, if you can explain more about what you’re trying to achieve that might help.


#3

@justincrabbe I 2nd where Sue is going here. 1 thing that pops out to me too is perhaps in the lifecycle you’re doing this at… the On Load. This function is triggered everytime a Page is created for the 1st time. Depending on the navigation structure of your Pages, you may be triggering this OR not triggering this when you don’t expect. adding some logic before it to ensure you have a good value in place for quote_count_number may be a good strategy to help troubleshoot here. It could be that the apps logic isn’t sound, like Sue said above.

A slick way to run this test too is to download your source code and run in the native Android Studio, if the app crashes, sometimes you can locate clues as to why in the logs provided there as well that might unlock an idea for solution as well. It’s what we do on our side a lot of time to try and dig a little deeper into situations and it’s a good and free tactic to employ on your side as well.


#4

Thanks @sue and @wade for your assistance on this.

Basically what’m trying to achieve is I have a list of Service Requests…

Initially, text that reads “QUOTES PENDING” along with an icon of a Clock are shown by default…

image

If the Quote Count_number >= 1 I set values to HIDE the clock + QUOTES PENDING text… and SHOW a single Number instead (i.e. 1,2,3,4 quotes etc.) whatver has been recieved.

I don’t know how to select ‘integer’ because i’m using bubble and the only data type i can select under the Quote Count is ‘Float’… Is there something else i should be doing here?

I cannot access the elements i need to show/hide on code 200 either and can only access them ‘on load’ it seems - is there something else that allows me to show/hide the elements?

Note that i’ve changed the structure heavily and had a number of test service requests submitted, some of those don’t have the field ‘Quote Count’ for example… are these entries causing an error somehow because they don’t contain the ‘Quote Count’ response?


#5

OK:

  • the number type should be fine, that was a “just in case” thing but I think highly unlikely to be the issue
  • if the elements you’re trying to update are inside the list tile then yes you’ll need to to do that in the tile load event
  • if the field is missing from some array items (rather than just being there but with an empty value or whatever) then yes I think that could potentially cause a problem
  • sometimes updating elements inside a list tile can not work because the elements are being reused inside the dynamic parent, however I find that crops up more commonly on ios so I’d be surprised if that’s the issue here

What I’d try next is a test adding a text element inside the list tile, and before your If Else add a Set Value to set the text of this new element to the quote count number value, that should give you a clearer idea what data is being received in each case and hopefully help to narrow down the potential source of the issue.


#6

I did what you suggested and put the text elements on the page and they’re displaying the correct information.

Now I’ve found more happening that’s very strange:

the 1st item in the list regardless of my if…else… doesn’t trigger the if…else… condition.

Everything seems to be working fine from item #2 onward in the list.

So now that i’ve added a number of other things for the purpose of testing, 2+ in the list work fine on the if… else… condition but item #1 never works or triggers the if/else.


#7

Hello Justin. Could you supply me with a Build ID and explain on what page to look and what’s going on here? I’ll be taking on the challenge with you moving forward here.


#8

Hi Wade, yes I’ll private message you the build ID now. Thank you.


#9

No Problem. Just so you know, Build ID’s do no one else good on here so they can be visible to the public. Without our internal access checkpoints, they don’t really mean anything to the outside.


#10

Good to know. I’ll do this next time and leave public.


#11

No Problem. Looking into your issue now.


#12

Wade, no one has helped me out on this.

Please update me on this bug.