7 Replies Latest reply on Sep 28, 2015 1:48 PM by inukshuk_99

# On a Claim Form - How to have a cell pick from a number and place in right box?

In Java...how to have cell 114 pick if NEGATIVE or cell 115 pick if POSITIVE ???

But stay blank if the number does not belong in the box ONLY the number goes in???

Thanks much

Inukshuk

• ###### 1. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

For the 144 field, you could use the following custom calculation script:

(function () {

var val = +getField("113C").value;

if (val < 0) {

event.value = Math.abs(val);

} else {

event.value = "";

}

})();

But replace "113C" with the actual name of that field. This assumes that you want to display the refund as a positive value, which is what the Math.abs method does. You can do something similar of the 115 field. Also, make the 114 and 115 fields read-only so the user won't be able to try to enter anything in those fields.

Note that this script could be simplified to:

event.value = +getField("113C").value < 0 ? Math.abs(+getField("113C").value) : "";

• ###### 2. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

Thanks for the reply...note the simplified did not work, but the top one did...

I need either 114 to display only if the GST113C is a (negative) -xxx number  and or to display in cell 115 if 113C is a positive number...NOT BOTH

Note that this formula with be put into each CELL 114 and 115, then the script will determine what to put in?

As you can see below...when code runs it displays in both CELLS and also does not show the - sign

When I paste the script into the editor for each cell...the number come into both...note that only 114 should have the number because its a -(negitive), but if the calc is payment then it belongs there

Thanks,

• ###### 3. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

The script for the 115 field should be similar, but not the same. Study the first one a bit so you understand what it's doing, and revise for the other field. If you get stuck, post your revised script.

Are you saying that you want the number to display as negative in the 114 field?

• ###### 4. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

Yes to display a negative number,

I did change the script for 115  "  if (val > 0)  "  and that worked

So now both Cells work, but the Refund still shows a positive number...needs to display a  say -1, 000.00   not 1,000.00

Thanks George

• ###### 5. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

Just get rid of the Math.abs, so it looks like this:

(function () {

var val = +getField("113C").value;

if (val < 0) {

event.value = val;

} else {

event.value = "";

}

})();

• ###### 6. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

Also George,

with that formula how do I add 2 cells together, or how to use SUM  see pic below...I used the prior formula, and now it does not show the 0.00 which is good...but I would like it to add 104 + 104 = 105...

Thanks

Kevin

• ###### 7. Re: On a Claim Form - How to have a cell pick from a number and place in right box?

I think I'm messing this PDF up...if you got time can you look it over...

Not sure how to post my PDF file...or can you PM me and I will forward?

Thanks,