Expand my Community achievements bar.

SOLVED

Restoring data from XML - guideBridge.restoreGuideState

Avatar

Level 7

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

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

This is what I got from my esteemed colleague in engineering

We cannot use dataXML directly to restore an adaptive Form(not supported as of today) The data can be restored only through dataRef, which means, data has to be uploaded to some URL and that URL has to be passed as options to restoreGuideState as specified in example here, https://helpx.adobe.com/aem-forms/6-2/javascript-api/GuideBridge.html#restoreGuideState__anchor

What was the use-case around using data directly during restore ? Were there any concern’s with using the guideState to restore an adaptive form ?

View solution in original post

4 Replies

Avatar

Employee Advisor

i am looking at this and will get back to you on this

Avatar

Level 7

Thanks! Let me know how you get on, even if you can't find a solution. Would be good to know it's not just me :-)

Avatar

Correct answer by
Employee Advisor

This is what I got from my esteemed colleague in engineering

We cannot use dataXML directly to restore an adaptive Form(not supported as of today) The data can be restored only through dataRef, which means, data has to be uploaded to some URL and that URL has to be passed as options to restoreGuideState as specified in example here, https://helpx.adobe.com/aem-forms/6-2/javascript-api/GuideBridge.html#restoreGuideState__anchor

What was the use-case around using data directly during restore ? Were there any concern’s with using the guideState to restore an adaptive form ?

Avatar

Level 7

workflowuser This is what I suspected from the docs and a quick look at the guidebridge code. Thanks for confirming.

I will be looking to use the guidestate Json for restoring, the reason for this question was due to a limitation with submitting the guidestate (it doesn't appear to be submitted as part of the Post request). I will accept this answer and raise a new question about that, it would be great if you could take a look at that as well! Bit of a catch 22

New question is Submit guidestate to REST endpoint

Many thanks,

James