4 Replies Latest reply on Jul 19, 2017 3:20 PM by James R Green

    Restoring data from XML - guideBridge.restoreGuideState

    James R Green Level 1

      Hi,

       

      I am attempting to restore data on my form using the XML.

       

      I have created a simplified test version of my form, with a few fields and two buttons.

       

      Button 1) Gets the XML

      Button 2) Attempts to restore the XML

       

       

      To get the XML I am doing the following:

       

      var getDataXML = function() {
         var XMLdata;
        guideBridge.getDataXML({
         success: function (result) {
         console.log(result.data);
         XMLdata = result.data;
        },
         error: function (result) {
         console.log("Get XML Failed to get the xml data");
        },
         guideState: null,
         boundData: true
         });
      
         return XMLdata;
      
      };
      };
      

       

      Then to restore it, I attempt the below:

       

       

      var restoreData = function (inData) {
      
        guideBridge.restoreGuideState({
         data : inData,
         success: function(guideResultObject) {
         console.log("successfully restored ",guideResultObject )
      
        },
         error : function (guideResultObject) {
         // log the errors
         console.log("error restoring state ", guideResultObject)
        }
        });
      
      
      }
      });
      

       

       

      The XML is extracted successfully, but restoreGuideState doesn't restore the information back on to the form.

       

      I am able to restore from a JSON string (obtained from guideBridge.getGuideState) successfully by changing line 4 in the restoreData function to:

       

      guideState : inData.guideState,

       

       

      But cannot get this to work for XML. Has anyone successfully done this? From the documentation it looks like the xml data has to be from a url:

       

      Adaptive Forms Class: GuideBridge

       

      Alternatively is there another way to load the form based on xml (dataXML)?

       

      Cheers,

      Jim