Validation with jscript

Hi @mdsmith1,

What do you mean that the logic has 'fallen apart' :thinking: It seems to be working as expected for me

Can you give an example input to try to reproduce the issue you're seeing?

Tess:

If you put in 2 passwords that match and they are both more than 7 characters long, are you getting messages that the passwords are too short?

Mike

Apologies for the delay in circling back!

I'm finding it helpful to add console logs so that I can see which part of the statement resolves to true.

It seems like there could be some cases that weren't accounted for yet. Looking at this documentation & my own testing, we can use "else if to specify a new condition to test, if the first condition is false."

In my screenshot, I have two mismatched emails & the first one is shorter than 8 characters (the first condition - the if statement - is true). Ideally, I would see the script is hiding container5 & showing container6. For container4, you could choose to just hide it since email1 is too short, or you could add more logic to check if they match

If I re-run the logic when email1 is longer than 8 characters and they match, I see that the else if statement is true & I'd ideally want the script to hide container4 & container 6, instead of 5

If I make the first email longer than 8 characters, but they don't match, I hit the else statement. Ideally, I'd want to see container4 and hide container5 & container6

I don't see any password inputs on the version that I looked at originally, so let me know if there is another version I should look at!

Tess:
I am still trying to figure out how to use console logs.

In the example below, I am trying to get an echo on how @count1 is being valued.

This second line below will not clear in MySQL Workbench.

Can you help me with this?

Mike

SET @count1 = (SELECT COUNT(invnbr) FROM Test01 WHERE Field1 = " ");
{console.log(@count1.value)};

Hi @mdsmith1 console.log will only work in a Javascript script or query - it will not work in MySQL

Hi Tess:

It would be very helpful if we could get the capability to echo values as the MySQL code unfolds. This would allow us to see if the MySQL steps are working as intended.

For consideration for upcoming improvements in Retool.

Mike

@mdsmith1 , mysql queries are run serverside on your server, until you do a select, no output will be created/sent to Retool.

The above code has a Select statement.

I think it should be evaluating to 4 but I have a feeling that it is evaluating to 0.

How do I write a Select statement that would show how it is evaluating the @count1 value?

Mike

Just do

Select @count1;

Mark:

Yes, your suggestion worked, thank you very much.

I ran it as stand alone and it worked. But I am trying to run a Stored Procedure and am having trouble with error messages.

Would you be willing to look at my Stored Procedure|?

Mike

Select @count1;
[/quote]

Mark

@mdsmith1 If you're still working on the stored procedure, would you mind posting some screenshots of the error messages in a new topic? Thanks!