Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Changing a field type programmatically?

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

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

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

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.

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

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.

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

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.

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

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?

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

15-12-2008

Not on the fly!!!

Avatar

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile

Avatar
Level 4
_Bill_Bain_
Level 4

Likes

0 likes

Total Posts

79 posts

Correct Reply

0 solutions
View profile
_Bill_Bain_
Level 4

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.