Hello,
I have used the code of the how to:
Allow Offline Use of a SharePoint List by Caching Locally
But I have a problem, when I disconnect my computer, my form uses the same data than the in the first xml file. But when I reconnect it, I have the updated data.
However, logiccaly, when offline, I should see the latest updated data. But it does not, any idea why?
Here is the code (which is the same actually, than in the how to):
try{
// Avoid DOM updates when the document has been digitally signed.
XDocument.DataObjects["MQuestDataIn"].Query();
// Get the ShareList DOM
var oDataIn = XDocument.GetDOM("MQuestDataIn" );
// Setup the Namespaces
oDataIn.setProperty("SelectionNamespaces",'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:tns="http://tempuri.org/"' );
// Get the local DOM - to does not use namespaces
var oLocalDom = XDocument.GetDOM( "Local Productys" );
// 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 Web Service List
var nlSharedItems = oDataIn.selectNodes( "/dfs:myFields/dfs:dataFields/tns:MQuestDataInResponse/tns:MQuestDataInResult/OdsChaudiaires/chaudiaires" );
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( "IDTYPECHAUDIAIRE" ).text;
nNewLocalCacheRow.selectSingleNode( "@Name" ).text = nSharedItem.selectSingleNode( "NOMCOMBUSTIBLE" ).text;
nNewLocalCacheRow.selectSingleNode( "@Description" ).text = nSharedItem.selectSingleNode( "NOMCOMBUSTIBLE" ).text;
// Append to to our local cached list
oLocalDom.selectSingleNode( "/CachedList/Products" ).appendChild( nNewLocalCacheRow );
}
}
catch(e)
{
// Uncomment this line for more debug information
//XDocument.UI.Alert( e.description );
// Tell the user that they must be connected to the Internet to use this feature.
XDocument.UI.Alert( "Vous devez être connecté pour avoir la version updatée des données.");
}