Reading values of Radio / Check button fields

Q: In our Acroform we defined a Radio Group Name called ‘SubTitle’ which has five physical buttons representing someone’s title like ‘Mr’,’Mrs’,’Miss’,’Ms’ or ‘Dr’. In the properites of each physical radio button the values are defined as ‘Mr’, ‘Mrs’, ‘Miss’,’Ms’ or ‘Dr’.

So when we try to retrieve the radio button selected we have the following code

f = doc.getField(“SubTitle”); // Values should be Mr,Mrs,Miss,Ms,Dr

if (f != null) sub_title = f.getValueAsString();

The Issue: what we are finding is that sometimes we are getting either an empty string, the value expected or a number like 0 or 3 returned

A: Since you are dealing with check/radio fields you should use GetValueAsBool() instead of GetValueAsString().