Thanks for the reply Patrick.
I've found a couple of examples that might work, but they are in J Script and I'm having trouble converting to C#. I think I'm pretty close here, but can't seem to get the last little bit. Directly below is the edited version of the example I found on InfopathDev.com. Below that is the unedited version of what I found.
If I'm on the right path and can get the loop working (big If's, I know), I think I'm golden.
Any insight on getting that while loop to loop thru the items in the List?
// NEED THIS DECLARATION IN C#
// I THINK IT WOULD BE:
// IXMLDOMDocument3 oSharePointDom = (IXMLDOMDocument3)thisXDocument.DataObjects["AccessLevelList"].DOM;
var oSharePointDom = XDocument.GetDOM( "AccessLevelList" );
// THIS APPEARS TO WORK AS IS... AT LEAST I GET NO COMPILE ERRORS AT THIS POINT
oSharePointDom.setProperty("SelectionNamespaces","xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'");
// I DON'T NEED THE LOCAL DOM SINCE I'M NOT RESETTING ANY ITEMS ON MY FORM, JUST LOOKING FOR THE ACCESS LEVEL.. SO I'VE REMOVED THIS PART
// I THINK THIS DECLARATION SHOULD BE:
// IXMLDOMNode nLSharedItems = oSharePointDom.selectNodes("/dfs:user_id/dfs:access_level");
var nlSharedItems = oSharePointDom.selectNodes( "/dfs:user_name/dfs:access_level" );
// WITHOUT THE LOCAL DOM TO COMPARE AGAINST, I'M NOT SURE OF THE SYNTAX FOR THE COMPARISON IN THE LOOP
// I DON'T HAVE THE "nSharedItem" FOR THE LOOP COMPARISON AND THERE IS NO "NEXTNODE" AVAILABLE IN C#
while( (nlSharedItems.nextNode() ) != null )
{
// ONCE INSIDE THE LOOP, I WILL RUN THE COMPARISON AGAINST THE USER_NAME
if(sUserName == nlSharedItem.selectSingleNode("@user_name").text)
{
sUserAccess = nlSharedItem.selectSingleNode("@access_level");
}
}
THIS IS THE CODE I CHANGED TO TRY AND MAKE IT WORK FOR ME IN C#:
// Get the updated version of the List
// If the user is offline, the code will skip to the "catch" block below
XDocument.DataObjects["Products Online"].Query();
// Get the ShareList DOM
var oSharePointDom = XDocument.GetDOM( "Products Online" );
// Setup the Namespaces
oSharePointDom.setProperty("SelectionNamespaces",
'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' );
// Get the local DOM - to does not use namespaces
var oLocalDom = XDocument.GetDOM( "Products Offline" );
// Get a sample cached list node that we will need to clone later
var nSampleProductNode = oLocalDom.selectSingleNode( "/CachedList/Products/Product" );
// Remove all of the items from the local copy of the list
oLocalDom.selectNodes( "/CachedList/Products/Product" ).removeAll();
// Loop through all of the items in the SharePoint List
var nlSharedItems = oSharePointDom.selectNodes( "/dfs:myFields/dfs:dataFields/dfs:Products" );
while( (nSharedItem = nlSharedItems.nextNode() ) != null )
{
// Create a new row from the sample
var nNewLocalCacheRow = nSampleProductNode.cloneNode(true);
// Set the values
nNewLocalCacheRow.selectSingleNode( "@ID" ).text = nSharedItem.selectSingleNode( "@ID" ).text;
nNewLocalCacheRow.selectSingleNode( "@Name" ).text = nSharedItem.selectSingleNode( "@Name" ).text;
nNewLocalCacheRow.selectSingleNode( "@Description" ).text = nSharedItem.selectSingleNode( "@Description" ).text;
// Append to to our local cached list
oLocalDom.selectSingleNode( "/CachedList/Products" ).appendChild( nNewLocalCacheRow );
}