1

I was using HTML component in home page component for advance search functionality in Narrow (Left) Column of Home Layout. My HTML component was

<script language="JavaScript" type="text/javascript">

function setFocusOnLoad() {}    

function submitSearchForm(){        
var searchField = document.getElementById('advsearchfield');        
document.advsrch.action = '/search/SearchResults?searchType=2&sen=0&setLast=1&str=' + encodeURIComponent(searchField.value);        
return true;
}

</script>

<form name="advsrch" method="post" onsubmit="return submitSearchForm();">
<input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr" /> 
<input class="btn" value=" Go! " type="submit" />
</form>

Now that component is not visible in Summer 15 org, so for the workaround I have created visualforce component and create VF page, below is my code of VF page

<apex:page >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" />
<apex:includeScript value="{!$Resource.advSearch}"/>
</apex:page>

advSearch.js (Static Resource) is

$(document).ready(function () {


function setFocusOnLoad() {}    
function submitSearchForm(){        
var searchField = document.getElementById('advsearchfield');        
document.advsrch.action = '/search/SearchResults?searchType=2&sen=0&setLast=1&str=' + encodeURIComponent(searchField.value);        
return true;    }

$form = $("<form/>",{name:"advsrch"},{method:"post"},{onsubmit:"return submitSearchForm();"} );
$form.append('<input class="searchTextBox" id="advsearchfield" maxlength="80" size="18" name="sbstr" />');
$form.append('<input class="btn" value=" Go! " type="submit"/>');

$('body').append($form);

});

After doing all the changes, I have found couple of issues

1) Its not showing the blue container as it is now VF component. Requirement is to show the advance search text field and button in blue container just like other components.

2) Its not calling the function same way as it was before, now it refreshing the whole page and not going link which I am providing.

Not sure what am I missing or whats need to be done. Any help would be appreciated.

Thanks much

1

Salesforce has disabled sidebar script injection and added some other limitations if you are using HTML home page component. Detailed discussion can be found in below link,

End of javascript sidebar workarounds?

0

1) Anyway the sidebar component won't show sidebar,header even if you use VF Area Component. So, for getting the blue background, don't use : sidebar="false", and showheader="false" in your VF page, ie used for "VF Area Component".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.