• Megan Brooks
  • 0 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 1
Taking my first stab at creating a custom button using Javascript, and it errors out with: Unexpected or Invalid Token. Hoping someone can help me identify what I've done wrong.

We are creating the button to pass data from a multi-picklist field into another multi-picklist field (pre-populated). Here's what I've got:

var FromPickListField ="{!Marketing_Request__c.Partner_if_applicable__c}"; 
var ToPickListFieldID ="00N55000000sZGW"; 
var FromPickListField = FromPickListField.split(";"); 
var Fields = "" ; 
for (var i=0;i<FromPickListField.length;i++){ 
Fields = Fields + ToPickListFieldID+ "=" + FromPickListField[i] + "&"; 

var URL = 
&cpn1=2016 CORPMKTING - MDF - 
&00N00000006xWKO = {!Marketing_Request__c.Submitter_Name__c} 
&cpn4={!Marketing_Request__c.Description__c}%20-%20 {!Marketing_Request__c.Goal_Description__c}%20-%20 {!Marketing_Request__c.What_is_it_that_you_want_to_do__c} 
&00N37000005x2QB=1" + Fields; 

    I am stumped! I have dug through the forums as well and nothing that I have found pertains to this specific issue, perhaps it is something really simple that I am missing. Any help would be great, here is my explanation: 

    I have built an email template with merge fields that loads perfectly on its own and linked it to a Custom Button via url link.  This does pull up the email template when the Custom Button is pressed but doesn't show any of the merge fields UNTIL I press the Select Template button and reselect the template that was specified in the url. I would like the merge fields to populate automatically and skip that extra step of having to reselect the email template. Any ideas?  Here is my url:

/_ui/core/email/author/EmailAuthor?&rtype=003&p3_mlktp=a13&p3={!Sales_Order__c.Name}&retURL=%2Fa13/o&p4=test@test.com&p5=test2@test2.com&p24={!Sales_Order__c.Tech_1_Email__c}&p6=Confirmation for {!Sales_Order__c.Job_Code__c}&template_id=00X17000000Qcqq