Date Picker Control

M

MarkP

Background: I setup a web sevice to retrieve data from a database, and also
save the form submission to the database. The retrieval and submission
processes work flawlessly. The fields are all bound inside a repeating
section bound to that dataset.
Question: I have several DatePicker controls on the form and for some
reason they always show up as required. I don't want them to be required. I
cannot figure out how to make a bound DatePicker control inside a repeating
section not required. The database allows nulls for these field, the xsd for
the dataset has no mention of them being required, so why does InfoPath
require them to be filled in?
 
S

Scott L. Heim [MSFT]

Hi Mark,

In order to remove the "Cannot be blank" option, you will need to manually
modify the schema. As such, before you complete these steps please be sure
you have a backup copy of your XSN file! :)

- Create a folder on your machine to store the InfoPath files
- Open your XSN in Design View
- From the File menu, choose Extract Form Files and choose the folder you
created above
- Now, depending on how your web service is designed you will probably have
multiple "XSD" files in this folder. You will need to open each, with say
Notepad, until you locate the schema that documents the various
attributes/elements for each field. For instance, in my sample that is
based on a web service returning three tables "schema3.xsd" is the one that
documents the "type", "minOccurs", etc.
- Once you find the appropriate schema, locate (for now) just one of the
date fields - for instance mine appeared as:

<xs:element name="OrderDate" type="xs:dateTime" minOccurs="0"/>

- You will need to add the "nillable" attribute to this element - such as:

<xs:element name="OrderDate" type="xs:dateTime" minOccurs="0"
nillable="true"/>

- Save and close the schema
- Right-click on Manifest.XSF and choose Design
- Click the Preview button - if you completed the modification correctly,
that date field should no longer contain a red asterisk!
- Complete the same steps for the other fields

I hope this helps!

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

MarkP

Your solution works perfectly. How do I get the files back into the xsn file
for deployment?
 
S

Scott L. Heim [MSFT]

Hi Mark,

That's great to hear!

To get back to a deployable XSN:

- Right-click on Manifest.XSF and choose Design
- From the File menu choose Save As (you will see in the File Type the only
option is XSN)
- Re-save to your XSN (again...assuming you have a backup!)

Let me know if you need anything else...

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

MarkP

Once again, right on the money. That was easy. OK here's a suggestion for
the InfoPath team... If a field in a dataset defined in a web service has
nillable="true" as an attribute, carry it forward to InfoPath. I have
nillable in my dataset definition and InfoPath ignored it during the wizard
to create a new template from a web service. That way a developer could set
the attributes on the webservice dataset to be nillable and not have to
extract, modify and re-cab files to make it work. I also have a suggestion
for the Visual Studio team, but that's another forum, but I give it you in
case you can get it to the right people... When building a dataset from a
database that has field with attributes of "NULLABLE" the dataset should
include that attribute also (eg. nillable) so that dataset would accurately
reflect the constraints of the peristence layer (in this case a database)
 
F

Fred

Hi Mark and Scoot,

I'm VERY GLAD to see that I'm not alone to think that that's a pitty that we
have to deal with the schema and modifying it by hand (with all the risks we
all know) while we are using InfoPath, Web services and Strongly Typed
Datasets....
Thanks Scott for your answer because this was missing to some of our projects.
Is there some news reagarding that with the 2007 version (or is it by hand
as well?)?
Thanks.
Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top