Handling NULL values

P

Paul Rayner

I have Infopath connected to a webservice that returns a typed dataset tied
to a SQL Server query. Many of the field values returned from the query are
NULL, and I am finding that these node elements are being dropped in the XML
returned from the webservice.

This wouldn't be such a problem, except Infopath will not allow the fields
bound to the missing elements to be modified in any way. I have searched far
and wide and the only option seems to be to remap the NULL values in my
webservice (on receive and submit) to empty strings and a default numeric
value etc., but this seems like such a hack and may cause problems with
numerics and booleans. I tried adding:

daLoan.MissingSchemaAction = MissingSchemaAction.AddWithKey;

into my webservice method prior to returning the Dataset, but it did not add
the missing nodes back in.

I would really appreciate some help with this. It seems to me that many
others would have had this problem I need to find a good solution soon.

Thanks,

Paul.
 
M

Michelle

In the infopath schema add nillable="true" to the elements that could be
returned as null. That should fix the problem.

Michelle
 
L

Li

What I do is adding empty node in xml file.
Maybe there is some other way I am also interested.

Thanks
 
P

Paul Rayner

I broke out the forms and updated every schema I could find to add
nillable="true", but it didn't make any difference.

I am at a bit of a loss now. I presume that you are suggesting I write
Javascript code to read through the schema and add in the missing nodes on
load. Is there anything like this that you can point me to?

Thanks,

Paul.
 
M

Matthew Blain \(Serriform\)

I'm suggesting first looking at optional sections--create an optional
section for every field which has issues.
If that doesn't work (including because you don't like the UI), you'll need
to add missing nodes somehow. One way to do this is to use the upgrade XSL
which InfoPath generates (through the upgrading form automatically)--run the
XDocument.XML through the XSL, then copy it back with replacenode. I don't
know of any examples around which use this technique, though I've done
similar things before.

--Matthew
 
P

Paul Rayner

Matthew. Thanks for the help.

I tried the optional section idea, but it does not handle the situation
where an incoming node is missing; the text box does not display at all. I
also tried using an upgrade.xsl file with no success. I have data in both the
main data source and a secondary data source that needs to have missing nodes
inserted.

I think the best way for me to do this is to search the DOM's using
Javascript and insert missing nodes. Do you know of any good examples of this?

Thanks,

Paul.
 
M

Matthew Blain \(Serriform\)

I'm surprised the optional sections don't work, though there may be some
tricks to getting them set up exactly right, I haven't done this very often.

You can certainly write code to go through and call CreateNode and
appendChild or otherwise as appropriate. Contact me directly (you'll have to
tweak my email address a touch) if you want some suggestions on this.
 
L

LarryFarrell

I am having a similar problem with surveys and I wonder if this was
ever resolved. My thought was to make SQL Server tables conform to my
need. I have two related tables, questions and answers. Questions are
generic. Answers are responses to the question on a per survey
response basis. Therefore you can have a question without an answer.
I was thinking that as soon as I create a document, perhaps I should go
and create all of the answers for all of the questions that apply to
this form and then load them. The answers would be blank, but the row
would be present.
Love to hear more about this problem and resolution.

--Larry--
 

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