Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

guideBridge API to prefill adaptive form with json

Avatar

Level 4

I am trying to prefill an adaptive form with json which is as per the json schema which I used to create the form. For testing purpose I have create a mock prefill data in the json format in a file and I am able to read that json and prefill form using the below guideBridge api:

guideBridge.restoreGuideState({

     dataRef : "file:///C:/Users/prefill.json",

     success: function(guideResultObject){

    console.log("prefill success");

     },

     error : function (guideResultObject) {

    console.log("prefill error");

     }

});

But in my use case I will be getting the json from a rest url and we need to send post some params to get that data. So I wrote an ajax call to get the jsonresponse. So Is there a way to include the jsonObject itself within the guideBridge.restoreGuideState api to prefill the data ? I have looked into the guidebridge documentation but didn't find anything related to this use case.

3 Replies

Avatar

Level 4

Any update on this query please ?

In the dataRef itself I can include a rest endpoint but even for that I need to post some params to get the response back. Is there a way to do that ?

Avatar

Level 7

guideBridge.restoreGuideState({

                guideState : response.guideState,

                error : function (guideResultObject) {

                    console.log('failed', guideResultObject);

                }

            });

My reply on the following post might help as a full example

https://forums.adobe.com/message/10202335

Avatar

Level 4

Thanks for the reply. In your example, the json which we get is the entire form guideState object. But in my case the JSON object should be in the format of the datamodel which i configured initially with the form. It should have the bound and unbound tags. In that way it will be prefilled automatically without writing the custom script. The dataRef url which I posted in the question gives me the json in that format itself. So I am checking to see if there is a way to pass that json to guideBridge.restoreguidestate function so that it will be prefilled.

I cant directly metion the url in the dataref itself because to that url (rest endpoint) I need to post params which I dont think it's possible with guideBridge.restoreguidestate function.