+ Start a Discussion
jyotijyoti 

Checking for special characters in variables in the URLFOR

 
We are retrieving Account Name which often has the "&" symbol in the name such as M & M Candy.  Because "&" also appears in the URLFOR to connect the URL string with the variables, anything after the "&" symbol in the name is truncated so that M & M Candy only appears as M.
 
Is there a function that can check for special characters (e.g. &) in the variables that are passed to a URLFOR?

var newURL = "{!URLFOR($Action.EMS_ORDER_FORM__c.New, null, [retURL=URLFOR($Action.Case.View, Case.Id)], true)}" + "&00N70000001wxOY="+caseRetrieveResults[0].Account.SE_NO_FORM__c +"&CF00N70000001wxOJ_lkid="+caseRetrieveResults[0].Id+"&00N70000001wxOC="+caseRetrieveResults[0].Account.ADDR_LN_1__c+"&00N70000001wxOD="+caseRetrieveResults[0].Account.ADDR_LN_2__c+"&00N70000001wxOK="+caseRetrieveResults[0].Account.CITY__c+"&00N70000001wxOm="+caseRetrieveResults[0].Account.STATE_PROVINCE__c+"&00N70000001wxOg="+caseRetrieveResults[0].Account.Account_Phone__c+"&00N70000001wxOS="+caseRetrieveResults[0].Account.COUNTRY_FORM__c+"&00N70000001wxOr="+caseRetrieveResults[0].Account.ZIP_POSTAL_CD__c+"&CF00N70000001wxOJ="+caseRetrieveResults[0].CaseNumber+"&00N70000001wxOZ="+caseRetrieveResults[0].PSD_ACTS_CALLER_NM__c+"&00N70000001wxOh="+caseRetrieveResults[0].PRD__c+"&00N70000001wxOn="+caseRetrieveResults[0].Account.FD_TAX_ID__c+"&00N70000001wxOE="+caseRetrieveResults[0].Owner.Email+"&00N70000001wxOU="+caseRetrieveResults[0].Account.DBA__c+"&00N70000001wxOX="+caseRetrieveResults[0].Account.Name;

werewolfwerewolf
Use the Javascript escape function on the strings you're getting from the merge fields.