+ Start a Discussion

Please help to Resolve my Escape Apostrophy problem from Command link in Custom lookup

Hi ,


Can anyone please help to resolve my issue.I am using custom lookup to search but soe of the name contianed appostrophy words because of that  i am not able to select them .


JSENCODE is also not working for this please find below my code


<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!JSENCODE(a.name)}', false)" rendered="{!actualCustType!='Partnerr'}">{!a.Name}</apex:outputLink>


What is the problem here can anyone please suggest.



Thanks in advance :-)))))



Hi Satyam

In one of my requirement for searching i wrote the code just see once may be it will help full to you.


<apex:includeScript value="{!URLFOR($Resource.jQueryui192custom, 'jquery-ui-1.9.2.custom/js/jquery-1.8.3.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQueryui192custom, 'jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jQueryui192custom, 'jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.min.css')}"/>
.ui-autocomplete-loading {
    background: white url("{!$Resource.Spinner}") right center no-repeat;
  <apex:form >
if({!redirectToThanku} == true)
window.parent.window.location.href = 'http://www.crowdchronicles.com/thank-you';

    var sObjects = '';
    var queryTerm;
            source: function(request, response) {
                queryTerm = request.term;
                ContactInfo.findAccounts(request.term, function(result, event){
                    if(event.type == 'exception')
                        sObjects = '[';
                        if(result.length == 0)
                            sObjects = null;
                            for (var i=0;i<result.length;i++)
                                sObjects += '{ \"label\": \"'+escapeSpecialChar(result[i].Name) + '\", \"value": \"'+escapeSpecialChar(result[i].Name)+ '\"},';
                            sObjects = sObjects.substring(0,sObjects.length-1); //remove last extra comma
                            sObjects += ']';    
                            sObjects = jQuery.parseJSON(sObjects);
            minLength: 2

    });//Ready function completes
    //Function to bring back special characters back into their original form
    function escapeSpecialChar(strToBeEscaped)
        var str = jQuery("#dummydiv").text();
        str = str.replace(/"/g,'\\"');  //Escape any double quotes if present in string
        return str;



here am calling these method in class,and am searching account name thats why i taken here account ,for you take on which object you want search.



//Feeds the matching accounts to Auto-Suggestion
    global static List <Account> findAccounts(string qry )
        String filter = ' like \'%' + String.escapeSingleQuotes(qry) + '%\'';

        //begin building the dynamic soql query
        String soql = 'select name';
        // add the object and filter by name to the soql
        soql += ' from account where name' + filter;
        soql += ' order by Name limit 10';
        List <Account> laccount = new List<Account>();
        //String accountNames = '\'[';
        try {
            laccount =  Database.query(soql);
        catch (QueryException e) {
            return null;
        return laccount;