• Rachel Brozinick
  • NEWBIE
  • 0 Points
  • Member since 2014
  • Rachel Brozinick

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hello,

I have a custom javascript button I built and I'm having issues with & characters clearing our my email subject.  Alot of our Account Names have '&' symbol in their name. This is my code below.  I tried JSENCODE and JSINHTMLENCODE and that didn't seem to work.  Are there any other suggestions that I could use to escape the &?

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}

//********* Option Declarations (Do not modify )*********//
var RC = '';var RSL='';var RSRO='';var RROS='';var CCRM='';var CCTM='';var CCNM='';var CRCL=''; var CRL='';var OCO='';var DST='';var LA='';var CEM='';var CES='';var STB='';var SSB='';var SES='';var SEM='';var SRS='';var SCS ='';var RES='';
//*************************************************//

//Adding Notes & Attachments
var LA='0';

//Custom Email Subject
var CES='Re: Agreement for On-Site Mobile Services from TestCompany, Inc.:';

//Custom Email Message
var CEM='{!JSENCODE(Account.Name)}\\n{!Contact.Name}\\n{!JSENCODE(Contact.MailingStreet)}\\n{!Contact.MailingCity}, {!Contact.MailingState} {!Contact.MailingPostalCode}\\n\\nRe: Agreement for On-Site Mobile Services\\n\\nPlease find attached our Agreement for Services (agreement) for {!Opportunity.Account}. The Agreement outlines the services to be provided by TestCompany, fee schedule and our general terms and conditions for your review and electronic signature.\\n\\nOn behalf of TestCompany, we look forward to the opportunity to serve your organization.\\n\\n{!Opportunity.OwnerFullName}\\n{!Opportunity.OwnerTitle}\\nexaminetics\\n{!Opportunity.Owner_Street_Address__c}\\n{!Opportunity.Owner_Address__c}\\n{!Opportunity.OwnerPhone}\\n{!Opportunity.OwnerEmail}\\nwww.testcompany.com';


//********* Page Callout (Do not modify) *********//
window.location.href ="/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Opportunity.Id}&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;
I have a DocuSign Button I am creating.  My client is sending from the Opportunity.  I want to be able pull a field called Dedicated_CS_Rep__c from the account related to that Opportunity.  Dedicated_Rep__c is a lookup field from the User.   Here's my code:

function getDedicatedCSRep (oppId) { 
var result = sforce.connection.query("select Opportunity.Id, Account.Name, Account.Dedicated_CS_Rep__c from Opportunity where Id = '" + oppId + "' "); 

if(!result || result['size'] != 1) { 
return null; 
} 

var AccountRep = result.getArray('records')[0]; 

return AccountRep.Opportunity; 
} 

var dedicatedContact = getDedicatedCSRep('{!Opportunity.Id}');

Whenever I try to send, i am getting this error:

User-added image

I did make sure there was a value listed on the Account that I was testing.  What am I missing?

Thanks!

Rachel
Hello, I am trying to pull the number of results from a query and returning the results.  Here's my code:

function getProductTypes (oppId) { 

var result = sforce.connection.query("Select COUNT() From OpportunityLineItem where OpportunityId = '" + oppId + "' and PricebookEntry.Product2.Name IN ('EAP') "); 

return result; 

}

This is how I am calling it:

if(getProductTypes('{!Opportunity.Id}') >= 1){ 

//do stuff here

} else { 

//do stuff here

}

What I am trying to do is find the number of product attached to the Opportunity.  If there's more than and equal to 1, i want it to run this code.  Else, run the other code.  Is my query and function correct or am I missing something?

Thanks!

Rachel


I have a DocuSign Button I am creating.  My client is sending from the Opportunity.  I want to be able pull a field called Dedicated_CS_Rep__c from the account related to that Opportunity.  Dedicated_Rep__c is a lookup field from the User.   Here's my code:

function getDedicatedCSRep (oppId) { 
var result = sforce.connection.query("select Opportunity.Id, Account.Name, Account.Dedicated_CS_Rep__c from Opportunity where Id = '" + oppId + "' "); 

if(!result || result['size'] != 1) { 
return null; 
} 

var AccountRep = result.getArray('records')[0]; 

return AccountRep.Opportunity; 
} 

var dedicatedContact = getDedicatedCSRep('{!Opportunity.Id}');

Whenever I try to send, i am getting this error:

User-added image

I did make sure there was a value listed on the Account that I was testing.  What am I missing?

Thanks!

Rachel
Hello, I am trying to pull the number of results from a query and returning the results.  Here's my code:

function getProductTypes (oppId) { 

var result = sforce.connection.query("Select COUNT() From OpportunityLineItem where OpportunityId = '" + oppId + "' and PricebookEntry.Product2.Name IN ('EAP') "); 

return result; 

}

This is how I am calling it:

if(getProductTypes('{!Opportunity.Id}') >= 1){ 

//do stuff here

} else { 

//do stuff here

}

What I am trying to do is find the number of product attached to the Opportunity.  If there's more than and equal to 1, i want it to run this code.  Else, run the other code.  Is my query and function correct or am I missing something?

Thanks!

Rachel


Hello!

I am in the process of building a javascript function and I am needing some assistance.  I want to be able to query all of a Opportunity's products to see if the field called Publisher__c =  EAP for any record.  If any of the records have the value of EAP in Publisher field, I would like to return a value of true.  If not, return else.  I need this information so I can pull the true or false value into another function to dictate what type of documents i need to pull.

function getContractType (oppId) {
var result = sforce.connection.query("Select PricebookEntry.Product2.Name, PricebookEntry.Product2.Publisher__c From OpportunityLineItem where OpportunityId = '" + oppId + "' and PricebookEntry.Product2.Publisher__c = "EAP"");

if(!result || result['size'] != 1) { 
	return FALSE;
    }
    
    var opplineitem = result.getArray('records')[0];

    return opplineitem.Product2;
}

var EbayContract = getContractType('{!Opportunity.Id}');