1

I have a javascript button that retrieves a few variables from a query:

var o = sforce.connection.query("SELECT Opportunity_Contact__r.FirstName, Opportunity_Contact__r.LastName, Opportunity_Contact_Email__c from Opportunity where id = '{!Advance__c.ApplicationId__c}'");

var OC = o.getArray("records");

var FN = OC[0].Opportunity_Contact__r.FirstName;
var LN = OC[0].Opportunity_Contact__r.LastName;
var EM = OC[0].Opportunity_Contact_Email__c;

--------------------
CRL='Email~'+EM+';Role~Signer 1;FirstName~'+FN+';LastName~'+LN;

window.location.href ="{!URLFOR('/apex/dsfs__DocuSign_CreateEnvelope',null,[SourceID=Advance__c.Id])}&DSEID=0&RC="+RC+"&RSL="+RSL+"&RSRO="+RSRO+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM+"&CRCL="+CRCL+"&CRL="+CRL+"&OCO="+OCO+"&DST="+DST+"&CCNM="+CCNM+"&LA="+LA+"&CEM="+CEM+"&CES="+CES+"&SRS="+SRS+"&STB="+STB+"&SSB="+SSB+"&SES="+SES+"&SEM="+SEM+"&SRS="+SRS+"&SCS="+SCS+"&RES="+RES;

EM is used in a URL and has the potential for special characters so I wanted to encapsulate in {!JSENCODE()}. It does not work on the javascript variable itself, coming back with the field does not exist, but it also doesn't work when setting the variable. Its not recognizing Opportunity_Contact_Email__c as a field even though that does exist in salesforce. Where would be the proper place to put this so the URL can handle potential special characters?

0
CRL=encodeURIComponent('Email~'+EM+';Role~Signer 1;FirstName~'+FN+';LastName~'+LN);

this worked

| improve this answer | |

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.