Expand my Community achievements bar.

SOLVED

Assign Dynamic Value to Email field with GuideBridge API

Avatar

Level 3

Hi, 

 

I'm having an issue with implementing GuideBride API. I have a adaptive form embedded on Dynamic page through AEM Form component. I need to assign Email address from api call to the email field in Form so it can be used to send email. 

 

I understand GuideBride can be used and I have put together a code to do that. But the event is NOT working consistently. Sometimes it work the other times it doesn't also if I open Chrome Dev tool then it works fine. This is my code. This issue driving me nuts. I try putting this code in footer, I debug the code. I see the event in Event Listener but when I close the dev tool it doesn't work on window refresh.

 

Am I missing anything?

 

window.addEventListener("bridgeInitializeStart", function (evnt) {
            // get hold of the guideBridge object
            var gb = evnt.detail.guideBridge;
            //wait for the completion of adaptive forms
            gb.connect(function () {
                //this function will be called after adaptive form is initialized
                var somExpression = "SOM_EXPRESSION_VALUE";
                var eligibilityAmountComp = gb.resolveNode(somExpression);
                eligibilityAmountComp.value = "testEmail@hotmail.com";
            })
        })

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi, 

Could it be caused by a race condition? I mean, could this be due to the "bridgeInitializeStart" event being triggered before you add the listener to your page? Perhaps using DevTools is delaying that, and that's why it is working in your debug environment. Although it may sound silly, you could try using a logger to check that everything is set in the right order.

Hope this helps



Esteban Bustamante

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi, 

Could it be caused by a race condition? I mean, could this be due to the "bridgeInitializeStart" event being triggered before you add the listener to your page? Perhaps using DevTools is delaying that, and that's why it is working in your debug environment. Although it may sound silly, you could try using a logger to check that everything is set in the right order.

Hope this helps



Esteban Bustamante

Avatar

Administrator

@snowwhite92 Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni