Google Custom Search box injection on Outsystems

Google Custom Search box injection on Outsystems


Hi Community,

I have a website built with Outsystems. Some of the pages have a form to submit some information and others have web block which has a form to submit some feedback. Recently I added Google Custom Search to the website and added a search bar (using HTML and JavaScript in a web block) on all the pages. Since then the forms on the site have stopped working. When the form is submitted all the fields/variables are blank. If I remove the web block, it works fine. My google search bar web blocks looks something like .... "

<form id='cse-search-box' action = '" + GetSearchPageURL() + "' method='get' onsubmit='return checkNull()' target='_parent'>
<input type="hidden" name="cx" value="<Google KEYS>">
<input type="hidden" name="ie" value="UTF-8">
<input type="hidden" name="filter" value="0">

 <div class='cse-container-2'>
<span class='search-cse-button' name='sa' value='Search' onclick='submitReset()'><i class='fa fa-search'></i></span>
<input type='search' name='q' id='search-text' placeholder='' oninput='inputFunction()' /></div>

When I look in the source code, the whole body every page is a form
<form method="post" action="<PageName>.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="WebForm1" name="WebForm1">

And the Google form is somewhere in that form. Is the issue due to nested forms? and how can I work around it? or am I missing something basic. Thanks

EDIT: I think the solution is to add my form element in the Body of the page but outside the top-level form. I am not sure how to do this, HTTPRequestHandler PostProcessingFilter is not working on my page. Suggestions?


Hello Kamran,

In fact having additional forms on the page can be tricky, due to the way ASP.Net works.

Instead of embedding Google's code, have you considered using their REST API and building the form in OutSystems? It might make things easier, and you'll get to control the look and feel of the whole search experience.

Best of luck,

PS: There's a Google CSE connector in the forge, but it's a bit old...