Assign value......OnLoad

H

hmoodangpp

Hi all,
I'm very sorry that I not good in English.
I have some questions that How I assign some values from XML file to the
InfoPath in OnLoad event. In assign value I mean fix value or hard code.
 
M

Madhuri Nishanker Rao

Hi
To add xml file to the form, you need to create data Connection.
To create Data connection you need to do in the following way:

1. On the Tools menu, click Secondary Data Sources.

2. The Secondary Data Sources dialog box appears.
3. Click Add.

4. The Data Source Setup Wizard starts.
5. Click XML Data File for the data source type, and then click Next.
6. Click Browse. In the Open dialog box, locate Xmlfile.xml, and then click
Open. Click Next.
7. Click Finish to complete the Data Source Setup Wizard. When you are
prompted to add the file to your form, click No.
8. Click Close to close the Secondary Data Sources dialog box.

Add the following code sample to the XDocument::OnLoad event handler.

XDocument.DataObjects.Item("XMLFile").Query();
var XMLFileDOM = XDocument.GetDOM("XMLFile");
XDocument.DOM.SelectSingleNode(DOM, “Xpath of the fieldâ€);


Save your changes to the script, and then close Script Editor
 
G

Greg Collins [InfoPath MVP]

You can either use Open Rules:
* Choose Form Options from the Tools menu. On the Open And Save tab, click Rules.

Or you can write code in the OnLoad event handler:
* Choose Programming | On Load Event from the Tools menu. Write code to populate the field values.
 

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