You need to sign in to do that
Don't have an account?
satyam
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: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')}"/>
<style>
.ui-autocomplete-loading {
background: white url("{!$Resource.Spinner}") right center no-repeat;
}
</style>
<body>
<apex:form >
<script>
if({!redirectToThanku} == true)
{
window.parent.window.location.href = 'http://www.crowdchronicles.com/thank-you';
}
jQuery.noConflict();
var sObjects = '';
var queryTerm;
jQuery(function()
{
jQuery("[id$='accountFieldAutoComplete']").autocomplete({
source: function(request, response) {
queryTerm = request.term;
ContactInfo.findAccounts(request.term, function(result, event){
if(event.type == 'exception')
{
alert(event.message);
}
else
{
//console.warn('result:');
//console.warn(result);
//console.warn(result.length);
sObjects = '[';
if(result.length == 0)
{
sObjects = null;
}
else
{
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);
//console.warn(sObjects);
}
response(sObjects);
}
});},
minLength: 2
});
});//Ready function completes
//Function to bring back special characters back into their original form
function escapeSpecialChar(strToBeEscaped)
{
jQuery("#dummydiv").html(strToBeEscaped);
var str = jQuery("#dummydiv").text();
str = str.replace(/"/g,'\\"'); //Escape any double quotes if present in string
return str;
}
</script>
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
@RemoteAction
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) {
System.debug(e.getmessage());
return null;
}
return laccount;
}