on 12-07-2014 6:55 AM
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My apologies - I didn't test that script before I posted it. I made three mistakes:
Also, the line "po_list = new Array();" shouldn't be there. I started with a script designed to do something else as edited it for your scenario, and forgot to delete that line!
Taking all those things into account produces this:
qntcol = 4; // Column number for the quantity field - check this!
rows = args.table[0].length;
args.pass = "Y";
for(i = 1; i < rows; i++) {
qnt = parseFloat(args.table[qntcol][i]);
// The validation goes here
if(Math.floor(qnt) != qnt) {
args.pass = "N";
}
}
I've tested this on a PO, testing for integer prices, and it works for me.
Steve.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.