Solved

Change a plain text field into a Rich Text field without loosing data

Posted on 2008-10-29
8
571 Views
Last Modified: 2012-05-05
I call it the Ikea moment. It's when you are almost done building and you realize that you've put something in backwards, and as a result you're going to have to redo the entire thing.

I seem to have an ikea moment with my infopath form. I had to update a template that our students use for doing writing activities.  There was a problem with content types on the sharepoint folder in which they are stored, so it seemed like the easiest way to do it would be to start from scratch. Unfortunately, when I tried to link the new template to the old files, none of the data showed up.

I had just finished spending the last two days recreating all the forms in the new template when I realized that one of the fields was set as text(string) or plaintext, when it should have been rich text. Doh!

I did a little searching and found that the way to accomplish this would be to edit the myschema.xsd file, but i can't seem to get it to work properly. I'm hoping that someone who knows xml better than me can help out here.

The post I found, (here: http://www.omgili.com/newsgroups/microsoft/public/infopath/5597EE8D-24D9-467B-A52D-B535D686B59Dmicrosoftcom.html&q=rich+text) suggests changing the xsd:element tag for the field in question. In my form, however; the "Work" field is only referenced as xsd:attribute, (possibly because it's a part of a repeating table) which won't accept the rich text complex type i copied from a test file.
            <xsd:complexType mixed="true">
                  <xsd:sequence>
                        <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/1999/xhtml" processContents="lax"/>
                  </xsd:sequence>
            </xsd:complexType>

Any help would be appreciated. I really don't want to have to go back again and redo all the forms in that folder.

Thanks!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<xsd:schema targetNamespace="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-10-27T17:45:48" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-10-27T17:45:48" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

	<xsd:attribute name="Number" type="xsd:string"/>

	<xsd:attribute name="Work" type="xsd:string"/>

	<xsd:element name="myFields">

		<xsd:complexType>

			<xsd:sequence>

				<xsd:element ref="my:StudentName" minOccurs="0"/>

				<xsd:element ref="my:Date" minOccurs="0"/>

				<xsd:element ref="my:Program" minOccurs="0"/>

				<xsd:element ref="my:LessonNumber" minOccurs="0"/>

				<xsd:element ref="my:Exercise" minOccurs="0" maxOccurs="unbounded"/>

			</xsd:sequence>

			<xsd:anyAttribute processContents="lax" namespace="http://www.w3.org/XML/1998/namespace"/>

		</xsd:complexType>

	</xsd:element>

	<xsd:element name="StudentName" type="my:requiredString"/>

	<xsd:element name="Date" type="xsd:date"/>

	<xsd:element name="Program" type="xsd:string"/>

	<xsd:element name="LessonNumber" type="xsd:string"/>

	<xsd:element name="Exercise">

		<xsd:complexType>

			<xsd:sequence>

				<xsd:element ref="my:Part" minOccurs="0"/>

				<xsd:element ref="my:Item" minOccurs="0" maxOccurs="unbounded"/>

				<xsd:element ref="my:Checkboxes" minOccurs="0"/>

			</xsd:sequence>

		</xsd:complexType>

	</xsd:element>

	<xsd:element name="Part" type="xsd:string"/>

	<xsd:element name="Item">

		<xsd:complexType>

			<xsd:sequence/>

			<xsd:attribute ref="my:Number"/>

			<xsd:attribute ref="my:Work"/>

		</xsd:complexType>

	</xsd:element>

	<xsd:element name="Checkboxes">

		<xsd:complexType>

			<xsd:sequence>

				<xsd:element ref="my:Checkbox1" minOccurs="0"/>

				<xsd:element ref="my:Checkbox2" minOccurs="0"/>

				<xsd:element ref="my:Checkbox3" minOccurs="0"/>

			</xsd:sequence>

		</xsd:complexType>

	</xsd:element>

	<xsd:element name="Checkbox1" nillable="true" type="xsd:boolean"/>

	<xsd:element name="Checkbox2" nillable="true" type="xsd:boolean"/>

	<xsd:element name="Checkbox3" nillable="true" type="xsd:boolean"/>

	<xsd:simpleType name="requiredString">

		<xsd:restriction base="xsd:string">

			<xsd:minLength value="1"/>

		</xsd:restriction>

	</xsd:simpleType>

	<xsd:simpleType name="requiredAnyURI">

		<xsd:restriction base="xsd:anyURI">

			<xsd:minLength value="1"/>

		</xsd:restriction>

	</xsd:simpleType>

</xsd:schema>

Open in new window

0
Comment
Question by:steam23
  • 5
  • 3
8 Comments
 
LVL 7

Expert Comment

by:CloudedTurtle
ID: 22840055
I created a quick test form with a StringField, and a RichTextBox (RTB) on the form. I saved a couple of XML files using this form, and then modified the form to change the StringField to a RTB. After I saved the form changes, and then opened the saved XML files, I didn't loose any data.
I recommend creating a small test area where you can work with a duplicate of the form template, as well as a copy of some of the form files (XML) that are saved by this form template. Work with these copies so that if you have any problems you are messing with the saved "production" information.
Here is what I did.
  • Open your form template in Design mode
  • From the View menu, select DataSource
  • Right-click on your field that is the StringValue, and select properties
  • In the DataType Dropdown select  "Rich Text (XHTML)"
    • When you do this, the form element (textbox) on your form will break the binding to the control, this is because you have the wrong control set for the datatype.
  • Select the Control on the Form and Righ Click.
  • Select "Change To", and select "Rich Text Box"
Once this is done, you can save the template, and new form will have the RTB for your field, and any existing for that was created with the earlier version will show the value that was entered in the String, in the RTB.
Note: If you make this change, it is much more difficult to change back to a StringField as you run the risk of loosing more data going this direction.
Hopefully, this helps you to some extent. If you need more details on anything just ask!

0
 

Author Comment

by:steam23
ID: 22840470
I think I'm beginning to see where the problem lies, though I'm not sure how it got that way.
I tried to change the Datatype to rich text as you suggested, but the option for Rich text isn't available. When I did I noticed that the Type is set as Field(attribute) rather than Field(element). Judging from my experiments with the myschema.xsd file, it seems that the RichText datatype can't be used within an attribute tag.  I can't imagine I would have set that field as an attribute, but I guess I should stop drinking while designing forms;)
I have a nasty feeling that if I delete the field(attribute) and replace it with a RichText element that I will loose the data in that field. I'm really hoping for a way around this. Any ideas?
0
 
LVL 7

Accepted Solution

by:
CloudedTurtle earned 500 total points
ID: 22841481
hhmm.. well I gave this a shot, but I think that you are plum out of luck.. I mean, not totally, you could change the Template XML and the Schema to match changing the attribute to an element, but then you would have to go through all the forms that were saved using the attribute and change the attribute value to be the element value..
One though that I had as I was typing.. would creating a new field called "Work1" that is an RTB, and then hiding the original "Work" field. Then set the default Work1 value based on the value of "Work"?? Does that make sense?
Basically, you add an additional column, hide the old one, and then create a rule that says "if there is a value in the old field, put it in the new one.."
This would allow you to move from the attribute to the RTB (hopefully) without any impact to the users, and without you needing to modify hundreds of forms..
What do you think?
0
 

Author Comment

by:steam23
ID: 22841817
I like the way you think! A little Infopath jujitsu!  I will give it a try and report on the results.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Closing Comment

by:steam23
ID: 31511375
Brilliant! that worked perfectly!
0
 

Author Comment

by:steam23
ID: 22842819
That did it!
I set the original field to a width of 1 px so it didn't mess with my design, and used conditional formatting to hide the field. The new rich text field is automatically updated on all the forms.
Thanks!
0
 
LVL 7

Expert Comment

by:CloudedTurtle
ID: 22842859
No problem, one more note, technically you can remove the control from the Form Template (as long as you don't delete the field from the datasource) then you don't have to worry about 1px controls in your form.. These might also come to haunt you in the future...
 
0
 

Author Comment

by:steam23
ID: 22895596
A quick update for anyone else using this solution.
The fix worked well, but I needed to open each form and resubmit it to the server to populate the new field. Once that was done, I could safely delete the old field.  I had missed this step, and as a result, users tried to edit old forms, and found that their work didn't look like it was being saved, since the next time they opened the form, the new field would be overwritten with the default value of the old field.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now