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
RainManRainMan 

Issues trying to replace the Contact "Clone" button

From looking at the html behind the clone button feature on contacts... it looks like it uses:
onclick="navigateToUrl('/003S0000002xxx/e?clone=1&retURL=%2F003S0000002xxx&scontrolCaching=1');"
 
It seemed simple enough... I just have to merge in the contact id into the url pattern and that's it.  So, I thought it would be easy enough to override that button with an scontrol that simply loads the same page with a few extra parameters... I got an example of this from the cookbook and here is my code attempt.
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<script src="/js/functions.js" type="text/javascript"></script>
<script>
 function init() { 
  var url = "/{!Contact.Id}/e—clone=1&retURL=%2F{!Contact.Id}"
      + "&WebID__c=0&Web2ID__c=0&scontrolCaching=1";
  navigateToUrl(url);
 }
</script>
<body onload="init()"> 
</body>
</html>
 
So... I thought I was good to go... but, everytime this button is clicked the page loads over and over again in an infinite loop.  I'm totally missing something.
 
The clone feature is cloning in our external identifiers for an integrated webapp we developed.  So, I wanted to to pass in 0 to clear them out.  I can't make them unique because they are uneditable by general users, I can't remove the fields from the clone feature (salesforce does not support this), I can't write an apex trigger to clear on insert... because our integrated app will write these identifiers on insert and they have to be preserved.
 
This Clone feature is loved by everyone... and now I am the bad guy for removing it.  Somebody please help.


Message Edited by RainMan on 10-23-2008 10:57 AM
JakesterJakester
You might be interested in a new app that we have just released on the AppExchange called PowerClone. It's capable of up to 99 copies of a record, allows you to define rules for how the copy works, and can also copy child objects. It's fully native code, so it runs fast and installs easily. Give it a try!
http://sites.force.com/appexchange/listingDetail?listingId=a0N30000001SRXAEA4
soofsoof

Try the following code:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head></head>

<script src="/js/functions.js" type="text/javascript"></script>

 

<script> 

function init() {

var url = "/{!Contact.Id}/e—clone=1&retURL=%2F{!Contact.Id}"

+ "&WebID__c=0&Web2ID__c=0&scontrolCaching=1&nooverride=1";

top.location.href = url;

}

</script>

<body onload="init()">

</body>

</html>

 

I've literally cut-n-pasted your code but changed two things.  The more important change is the addition of nooverride parameter and setting it to 1.  Since you've overridden the Clone button, whenever the Clone function is invoked, your S-Control will be loaded.  If you pass the nooverride parameter (setting it to 1) in the URL, the native Clone page will be loaded, with the additional parameters that you wish to pass.

 

The second change is to direct the main window (instead of the IFRAME) to the Clone page, because your S-Control will load in an IFRAME, and that's where the JavaScript will execute.

 

A suggesion/best-practice is to use the URLFOR() method to create the URL instead of hard-coding.

 

Hope this helps!

 

-soof 

 

SAKOSAKO

Hi RainMan,

 

I tried to find the mentioned Code in the Cookbook. Where did you find it? Do you still have the Code somewhere stored?

 

Thanks in advance and cheers,