DataObjects Collection


DataObjects Collection

The DataObjects collection contains a DataObject for each of the secondary data sources used within an InfoPath form. Each object provides access to a specific data adapter that is used to connect to the external data source, as shown in Table A.9.

Table A.9: DataObject Collection Properties.

Name

Security Level

Description

Count Property

1

Returns the total number of DataObjects contained in the current collection

Item Property

2

Returns a reference to the specified data object

Note  

This object does not allow you to create, add, or delete existing data objects that are created during design time.

Listing A.2 is from the Sales Call Form. This code accesses a DataObject object and programmatically changes it to return a specific database search.

Listing A.2:
start example
 //Get the current value of the resource dropdown. var resourceValue = eventObj.Source.text //Construct a new command for the second dropdown listbox using a Where  clause... XDocument.DataObjects("NextStepsUpdate").QueryAdapter.Command =  originalSQLQuery1 +" WHERE NextStepItem='" + resourceValue + "'" //Requery the data source XDocument.DataObjects("NextStepsUpdate").Query(); //Set the "SelectNamespaces" property so we can do selectNodes calls on  the resource's DOM XDocument.DataObjects("NextStepsUpdate").DOM.setProperty("SelectionName spaces",  'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"  xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" ' ); //Get a reference to the list of resources var objTitleViewResources =  XDocument.DataObjects("NextStepsUpdate").DOM.selectNodes("/dfs:myFields /dfs:dataFields/d:Next_Steps" ); //enumerate the TitleViewTitles, and add a AvailableTitles for each one for (i=0; i < objTitleViewResources.length; i++){     //update the other values     var nextStepNote = objTitleViewResources.item(i).selectSingleNode(  "@NextStepNotes" ).text;   } // update the repeating section updateSteps(nextStepNote,eventObj); //Force the view to refresh XDocument.View.ForceUpdate(); 
end example
 



Programming Microsoft Infopath. A Developers Guide
Programming Microsoft Infopath: A Developers Guide
ISBN: 1584504536
EAN: 2147483647
Year: 2006
Pages: 111
Authors: Thom Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net