function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mauricio.ramos@corpitalmauricio.ramos@corpital 

Error in custom email PDF button (with javascript)

I have a custom button on a custom object that executes some javascript which calls a web service method and populates parameters to call the EmailAuthor link in SF. In sandbox it is working just fine and the code I cannot see any difference. The problem is when I click the button in production I get the following message:

 

The value of the "p3_lkid" parameter contains a character that is not allowed or the value exceeds the maximum allowed length

 

This is the code of the button:

 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var docId = sforce.apex.execute("SalesDoc_PDFAttachment","getSalesDoc_PDFDocument", {salesDoc_ID:"{!SCRB_SalesOrder__c.Id}",pAttID:"{!SCRB_SalesOrder__c.Active_PDF_Attachment_ID__c}" });

 

location.replace('/_ui/core/email/author/EmailAuthor?retURL=/{!SCRB_SalesOrder__c.Id}&p2_lkid={!SCRB_SalesOrder__c.Selling_ContactId__c}&rtype=003&p3_lkid={!SCRB_SalesOrder__c.Id}&doc_id='+docId);

 

I cannot see any errors and when the link is executed the values populated into the url are:

 

 

retURL= the id of the custom record

p2_lkid= the contact to send the email to

p3_lkid= the id of the custom record

doc_id= the ID value of the SF document returned by the web service method.

 

Can anyone spot where this is failing?

Best Answer chosen by Admin (Salesforce Developers) 
mauricio.ramos@corpitalmauricio.ramos@corpital

I have found the problem and wnated to share it here so it may help someone else someday:

 

The problem was that the production custom object did not have the Allow Activities checkbox checked and therefore would not allow the sending of email and saving into a task.

 

The solution was simply to check the checkox and save the custom object definition and the button started working again.