How does xdExtension pass values

D

djasek

Does anyone know how the xdXDocument:GetDOM() actually pass the
XDocument?

I am trying to setup a function in managed code that will be called
from a conditional formatting in InfoPath. I want this function to
return an XDocument that the conditional formatting expression will
extract a field from.
When I use the builtin GetDOM it works fine:
xdXDocument:GetDOM("other data")/somegroup/field

But I can't figure out what to pass back to get this to work from my
own function. When I try to pass back an XDocument and do something
like this:
xdExtension:MyFunc()/somegroup/field

I get an error that says MyFunc does not return a value that can be
used.
Is there any way to get this to work?
Or is GetDOM some special function that uses components I can't
access?

Thanks,
-Dan
 
D

djasek

Yea.
I can get xdExtension to work fine when I'm passing a string. And all
the examples I can find are using simple strings.
I'm trying to do something a bit more difficult. I want to pass an
XDocument, not just a string.
InfoPath does it internaly with its xdXDocument:GetDOM() function, but
I can't figure out how it does it...

-Dan
 
S

S.Y.M. Wong-A-Ton

I do not have a clear picture of what you're trying to do, so cannot give you
any concrete pointers, but I don't think the xdExtension was meant to return
complex data types like XmlDocuments. But then again, in the past I've come
back many times to prove myself wrong.

If the schema of the XML you are trying to return is static, but the XML
data itself dynamic, you could try adding the schema as a secondary data
source to your form, fill it with your data, and use the method described in
the second part of the link I previously referred to to set conditional
formatting. Conditional formatting is triggered by value changes on fields,
so you can use a Changed event somewhere to provide your functionality.
 
D

djasek

My problem is a bit more complex than that, I can't use a simple
secondary data source. I was simplifying it so I didn't have to write
a long essay with a bunch of irrelevent info. I can make a work-
around, it just won't be nearly as elegant, and will be a lot more
coding.
It looks like there isn't a solution, but just to clarify, in the
simplist terms, this is what I need to do:
I have a expression in InfoPath:
xdXDocument:GetDOM("Second Data")/my:Group1/my:Field1 = "value"

works fine. I want to rewrite it to:
xdExtension:myFunc()/my:Group1/my:Field1 = "value"

where:
public XDocument myFunc()
{
return thisXDocument.GetDOM["Second Data"];
}

Which doesn't work.
The obvious answer is that you can't pass an XDocument into an
expression like that.
But it is done internally by xdXDocument, so there should be a way.
Which is frustrating.

-Dan
 

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