hclleapforum

Open full view…

New to LEAP and losing my mind a little bit

steven_d
Wed, 18 Sep 2019 16:56:40 GMT

I'm finding that quite a bit of the functionality I expect to work, based on my version of common sense, doesn't seem to be working out. I've had to resort to putting a bunch of extra code into my events to figure out why things aren't working out for me. Case in point, I'm trying to build a login page. My login page has two sets of credentials and it has a button (appropriately titled "Login"). So the gist of it is that the "Login" button state should be inactive until the user has entered passwords into the password fields according to the min/max length of the given credential. For instance, the credential based on Windows AD must be at least 8 characters and no more than 20 while the credential based on a token must be exactly 10 (4 character pin + 6 character random token). The logic I had for making this determination wasn't working so to test the logic I added text fields to the page that I would update with the length of each password field every time the event "onLiveItemChange" fires. Well, it doesn't. To be clear, it does update the text field SOMETIME S (it fires). Just not every time. Which seems a bit odd. The firing of that event seems like it should be a very binary thing. It either fires or it doesn't fire. Here's a sample of the code: /* Add your own JavaScript here. */ //alert("F_NetMRIPassword.onItemLiveChange"); //alert(BO.F_NetMRIPassword.getValue()); //alert("Length of F_NetMRIPassword is " + BO.F_NetMRIPassword.getValue().length); //alert("Length of F_ACIPassword is " + BO.F_ACIPassword.getValue().length); page.F_TextNetMRIPasswordLen.setContent(BO.F_NetMRIPassword.getValue() .length); page.F_TextACIPasswordLen.setContent(BO.F_ACIPassword.getValue().lengt h); if (((BO.F_NetMRIPassword.getValue().length >= 8) && (BO.F_NetMRIPassword.getValue().length <= 20)) && (BO.F_ACIPassword.getValue().length == 10)){ alert("Evaluating..."); page.F_Button1.setActive(true); // alert(page.F_Password1.getValue()); // alert(page.F_Password2.getValue()); } else { //alert("Not matching!"); }

marty_lechleider
Fri, 27 Sep 2019 14:43:07 GMT

I have tested a few things and have found that I am unable to get the length with the onLiveChange. We will look into this to see if this is a limitation of the event or a bug in the sw. As an alternative you could use the onChange event and test against JS if statements or even use a regex pattern. If the condition you want is not met you can then set the item to invalid (i.e. BO.F_Password1.setValid(false, “passwords must be between 4 and 20 characters”) ) and also set the button to setActive(false).

christopher_dawes
Fri, 27 Sep 2019 19:41:05 GMT

When using onLiveItemChange the getValue() function will always return empty. Instead you need to use getDisplayValue(), this will return you what has currently been entered, as the value at the data layer has not been registered. I hope that this simple change will enable you to move forward.