These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

If-then "do nothing"

cflynn233
Registered: Apr 19 2010
Posts: 11
Answered

I read up on writing conditional statements and didn't find my answer...so I apologize in advance if I just missed it.

I am using simplified notation in a field to get a percentage when two other fields are divided. Unfortunately, it leaves me with errors when either of these fields are blank...and I plan to forward this as a blank form when it's complete.

I have the following fields:

"Income"
"MSA"

...which when divided give me:

"percent_MSA"

When either [Income] or [MSA] are blank or "0," I am given the error:

"The value entered does not match the format of the field [ percent_MSA ]"

While I know this is only temporary, and filling in the fields negates the error, it's an annoyance I would like to get rid of before I forward the form to our users.

My thinking is that by using a conditional stating that if [income] or [msa] are null, [percent_msa] should be null as well. Does this work? And if so, what's the coding?

Thanks
-Chris

My Product Information:
Acrobat Pro 9.3.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
For "Simplified Field Notation", "Simplified" is the operative word for not only the field object but any any item other than the field's property value or a constant. The "Simplified Field Notation" does not support any flow control statements, does not support any object properties except value, does not support any object methods, does not support any functions, does not support any constrictors, etc. For anything beyond the field's value you need to use a custom script.

George Kaiser

cflynn233
Registered: Apr 19 2010
Posts: 11
Sorry...I meant to state that I understand that I'd need a custom script. Right now, I'm using simplified notation to calculate only the percentage, and that is what's causing the issue whenever one or both of the fields are null.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You can use code similiar to the following as a 'custom calculation script';
// change field name strings as needed// divisor field namevar sDivisor = 'Income';// dividend field namevar sDividend = 'MSA'; event.value = 0; // assume do nothing// get divisor's valuevar nDivisor = this.getField(sDivisor).value;// test for non-zero divisorif(nDivisor != 0) {// we have a non-zero divisor// get the dividend's valuevar nDividend = this.getField(sDividend).value;// perform the divisionevent.value = nDividend / nDivisor;}

George Kaiser

cflynn233
Registered: Apr 19 2010
Posts: 11
Thanks for your assistance. That did the trick.