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

Setting a fields value to null and not just "" (empty string).

AndrewAlb
Registered: Aug 16 2007
Posts: 97

I too an interested in this - I have a code that interacts with two fields - and you can only put data in one of the fields. So upon entering field B adobe checks to see if field A is null - if it is not an alert pops up and says "You can only have data in one field, shall I erase the data in the other field". Now, I can just put an empty string (value = "") but then that is not the same thing as null and so my code breaks down and even when the cell is empty (contains a zero length string "") the error message still runs. So I need to make it null and not just "" - how can I do this?
(by the way if it matters, it is a number field). Here is the code:
 
var FedDol = this.getField("IncomeTaxWitheldFederalPercent");
 
//Check to see if the other field is null
if (FedDol.value != null)
 
//If it is null run the alert
var nRslt = app.alert("Only one federal value may be entered - either dollars or percentage.\n\n" + "Shall I erase the percentage value in order for you to add a dollar amount?",2,2,"Warning");
 
//If the users selects 'yes' make the other field null
if(nRslt == 4)
FedDol.rawvalue == null;
— AndrewAlb

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

My Product Information:
Acrobat Pro 7.0.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You are mixing AcroForm and LiveCycle code. For example, your "FedDol" field is acquired with an AcroForm function, "getField", it does not have a "raw Value" property. This is an XFA form field property. Don't do this.

Either forms technology will allow you to set null values, but you have to use the correct syntax for that technology.

A better way to do your test is use regular expressions. That way you catch the situations where the user enters spaces.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script