Copying values from a secundary data connection to my primary

J

Jose Cebrian

Hia all:

I'm working with InfoPath 2003 SP1. I need to create a survey using
InfoPath, with "survey" i mean a set of pairs of questions and answers.

The problem is that the questions of the survey must be created dinamically
depending on the values of some fields.

So, my main Data Source has a repeting group that stores the couples of
questions and answers.

Something like this:

(Repeating Group) Items
ItemQuestion
ItemAnswer

To obtain at runtime the set of questions needed, i have created a secundary
connection to SQL and modified the "XDocument.DataAdapter.Command" to query
the values that i need.

The secundary connection can be as simple as this:

(Repeating Group) Questions
ItemQuestion

The problem is how to assign the values of the secundary data connection to
my primary. That is: for each (secundary.ItemQuestion --> main.ItemQuestion)

I have tried to program a rule that copy the field of the secundary to the
field of my primary, but this only copy the first record.

Can somebody please help me?

Thanks!
 
S

S.Y.M. Wong-A-Ton

You'll have to use code. I haven't yet found a way to do this without code.

You'll need to retrieve the secondary data source, loop through it while
creating and adding nodes to your main data source. Another way is to use an
XSLT transformation that will convert all of the nodes in your secondary data
source into nodes that will fit in your main data source.
 
J

Jose Cebrian

Thank you.

Usiing code now i'm able to obtain all the data i want from the secundary
data source. Which is the way to create new nodes in my primary to map the
fields?

By the way, this is the code i'm using to access to my secundary data source
to recover the data i need. Hope that is useful for somebody:

var secondDSDOM = XDocument.GetDOM("secondDS");

secondDSDOM.setProperty("SelectionNamespaces",'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-11-13T16:30:36" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');

var texto =
secondDSDOM.selectNodes("//dfs:myFields/dfs:dataFields/d:secondDS");

for (i=0; i < texto.length; i++)
{
XDocument.UI.Alert(texto.item(i).getAttribute("Column1"));
}
 
S

S.Y.M. Wong-A-Ton

If you have a repeating group/section in your main DOM, you can use the
cloneNode() or the CreateDOM() method to create a child node for the
repeating group/section. Copy the values over from a node from the secondary
data source, and then use appendChild() to append the node to the repeating
group/section. Search this newsgroup for the methods I've mentioned and you
should be able to samples online.
 

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