Changing a field type programmatically?

Avatar

Avatar

_Bill_Bain_

Avatar

_Bill_Bain_

_Bill_Bain_

14-12-2008

We have a form that generates an XML file that is emailed to Word Processing to get merged into a Word document. The form uses a table to totalize some columns. The client now wants any cells in which the value is null to read "N/A" in the Word document. It's easy enough to make the form *display* N/A, but to put "N/A" in the fields so that the word processor doesn't have to search and replace, I'd like to change the affected fields to text fields programmatically and set them to "N/A" so thst the XML file fields would have the "N/A" value that would be picked up by the Word mailmerge.



Is there a way to do that?

Replies

Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

15-12-2008

How big is the form? How many fields? If it is not too big you could loop through each onject in the form, test its value and if it is null set it to N/A. Or you could have an initial value of NA instead of null.
Highlighted

Avatar

Avatar

_Bill_Bain_

Avatar

_Bill_Bain_

_Bill_Bain_

15-12-2008

It's 8 fields, well 9 if you count the total field, so I really don't even need to loop through the entire form. The fields are numneric so that if there's a number that is input, the total field will totalize properly. The problem is that the 8 fields are scattered throughout the Word document so if I could have the XML output file values for the fields be "N/A" instead of null or "00", it would save the word processors time doing search and replace.
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

15-12-2008

Once you change the field value to NA then the calc will refire and an error will be generated because you are adding a string to an float.
Highlighted

Avatar

Avatar

_Bill_Bain_

Avatar

_Bill_Bain_

_Bill_Bain_

15-12-2008

Yup. That's what I thought, so it's not possible to change the type of field from numeric to string if the value is null?
Highlighted

Avatar

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692

Avatar

pguerett

Total Posts

7.7K

Likes

611

Correct Answer

692
pguerett

15-12-2008

Not on the fly!!!
Highlighted

Avatar

Avatar

_Bill_Bain_

Avatar

_Bill_Bain_

_Bill_Bain_

15-12-2008

Well, win some, lose some! 🙂 Since it's a relatively small number of fields, I think I'll just set up some additional text fields, and if the numeric fields aren't null, load the text fields with the numbers as strings since they've been totaled already. If the numeric fields are null, load the text fields with "N/A". Then I can have Word pick up the text fields instead of the numeric fields.



Thanks for getting back to me.