Friday, April 9, 2010

How to "Unlock" a data source schema (.xsd)

REF: http://www.infopathdev.com/blogs/hilary/archive/2009/03/13/locked-schema-got-you-down.aspx

Locked Schema Got You Down?
Sometimes we want to create a new template off an existing schema. Microsoft has a great article Here , but for those of you who have already created a form off an existing schema, and just want to know how to unlock it, it can be a bit much to dredge through (also, they don't even mention the little .xsf hack I'm going to show you....). Fortunately, you have me, and I feel your pain.

The Problem

You saved a beloved form as source files, because its schema was perfect, and you want to base another form off of it. You create a new form template, chosing XML or Schema for the source

and you happily design away... until you want to add a field. Or change the name of an existing field. That's when you realize.... you're stuck. See those little locks on the data fields? And at the bottom of the Data Source Task Pane, Add a Field or Group is grayed out....

The Reason

If you read the article I've linked in the first paragraph, it says:

When you design a form that is based on an external schema, Microsoft Office InfoPath 2007, or Microsoft Office InfoPath 2003 assumes that the schema is finalized and therefore prevents any modification of the schema in the Data Source task pane.

So there you have it. InfoPath figured you were perfectly happy with the schema when you built the form off it.

One Solution

You can manually add elements to your schema. Save your form as source files and open myschema.xsd in a text editor.
Another Solution

But what if you just want it unlocked, so you can add fields like a normal old data source? For that, again, we need to save as source files. Open manifest.xsf with a text editor. Look for your schema file in the files element. You'll see a property named editability which has helpfully been set to 'none':

Set this property to 'full':


Save your changes, and open your template in design mode again:

All your fields will be fully editable.

The Usual Warnings Apply

Save a copy of your form someplace safe before manipulating form files. This is by no means a full discussion of potential pitfalls that can be encountered -- more information on xsf structure is available here. Happy unlocking!


Published Mar 13 2009, 05:32 PM by Hilary Stoupa

More:
REF: http://www.infopathdev.com/forums/p/9499/33583.aspx