Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9091

Re: How to validate a value is float/double in a column-personas 2

$
0
0

To check if a number is an integer you'll need to use JavaScript. A Math function would work - something like Math.floor(x) == x. Or you could use a string test to look for non-zero characters after the point.

 

You'll also need to use Javascript to loop through the table as you can't do that in native Personas 2 scripting. Start with a Copy Table action - say that creates a copy called "table". The JavaScript would then look something like this:

qntcol = 6;     // Column number for the quantity field - check this!

rows = args.table[0].length;

po_list = new Array();

args.pass = "Y";

 

// Now validate all the quantities for(i = 0; i < rows; i++) {      qnt = args.table[qntcol][i];

     // The validation goes here

     if(Math.floor(qnt) != qnt) {

          args.pass = "N";

     }

}

 

After this, you will have a variable called "pass" you can check in the Personas v2 script. It will have the value "Y" if the test passed - i.e. all the values were integers - and "N" if not. You can enhance the JavaScript to also record which row failed, so that you can include that in any error messages - "Line 4 had a non-integer quantity".

 

Steve.


Viewing all articles
Browse latest Browse all 9091

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>