If you are Overriding an Existing standard Contact Page with a custom Visual-force Page of managed package and your Salesforce

instance is https://na1.salesforce.com, 


Then the new URL will be as below to access Contact detail with custom page -:


https://ManagedPackage_PackagePrefix.na1.visual.force.com/apex/Candidate


When you try to send SMS from such custom VF page of managed package, it might give you error as "URL no longer exists" due to wrong return URL set.


Our Standard Send SMS button script is as below-:


{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} 
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-1.10.2.js')} 
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-ui-1.10.4.custom.min.js')} 
{!REQUIRESCRIPT("/resource/smagicinteract__sendSMSJS")} 

var packagePrefix = "smagicinteract__"; 
var recordType = 'contact'; 
var idToUpdate = '{!Contact.Id}' 
var nameField = 'Name'; 
var mobileField = 'MobilePhone'; 
var optOutField = 'smagicinteract__SMSOptOut__c';
var optOutDefaultValue = 'yes';
var smsType = ''; 
var userId = '{!$User.Id}'; 
var elementIdVar = ''; 
var showUserDropDown = false; 
var dialogTitle = '';
var cssUrl = '{!URLFOR('/resource/smagicinteract__smJQuery/css/sm-theme/jquery-ui-1.10.4.custom.min.css')}';
var unrelatedObjectAPIName = '';

sendSMS(recordType, idToUpdate, userId, nameField, mobileField, optOutField, optOutDefaultValue, smsType, elementIdVar, packagePrefix, showUserDropDown, dialogTitle, cssUrl, unrelatedObjectAPIName);

  

Solution-:

To resolve this problem, we need to do changes in button script as below-:

 

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} 
var packagePrefix = "smagicinteract__"; 
var recordType = 'Contact'; 
var idToUpdate = '{!Contact.Id}' 
var nameField = 'Name'; 
var mobileField = 'MobilePhone'; 
var optOutField = 'smagicinteract__SMSOptOut__c'; 
var optOutDefaultValue = 'yes'; 
var smsType = ''; 
var userId = '{!$User.Id}'; 
var elementIdVar = ''; 
var showUserDropDown = false; 
var dialogTitle = ''; 
var queryString = parent.window.location 

var url = "/apex/"+packagePrefix+"BulkSendSMS?retURL="+queryString+"&nameField=" +nameField +"&phoneField="+ mobileField+"&optOutField="+optOutField+"&optOutDefaultValue="+optOutDefaultValue+"&objectType="+recordType+"&showUserDropDown="+showUserDropDown+"&recordIds="+idToUpdate;
parent.window.location = url;

 


Make these changes and then try to reproduce the issue. If it persists, feel free to write us on care@screen-magic.com


When you just have VF page but it does not belong to managed package then please click here for detail solution.