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
LindbergOriLindbergOri 

How to override the functionality of default buttons in Winter '07?

I've heard that Winter '07 allows to override the functionality of many buttons... including 'new', 'save', 'edit' buttons.  Once overridden, anytime that someone creates, saves, edits an object of that type (from the objects 'new', 'save', 'edit' button on it's tab) then customized code (script code) will be run.
 
Then how to do it and achieve that? Using snippet s-control?
 
LindbergOriLindbergOri

Yeah! I got it. From the "Buttons and Links", click "Override" link and choose a s-control written by yourself.

But another question is, If I just want to "append" my function to the default button, that means I just want to add my script code as a new part to the original button functionality, is there any way to do it? If I write a page myself, of course the out look is weaker than the default beautiful pages, though the function may be nearly the same.  

Doug ChasmanDoug Chasman
When you override a button you are not really changing the code behind the button - instead you are esentially remapping where the url that the button refers to will take you. This is a very powerful concept - basically regardless of the way that a user navigates (button, link, etc) they will be taken to your scontrol. There is a mechanism in place to allow you to "forward" to the default behavior after going to your override scontrol that you might want to leverage here.

Can you provide some more details on what it is you are trying to accomplish. In some cases I've found that an easier approach is to use another new feature of Winter '07: inlined/embedded scontrols.
LindbergOriLindbergOri
For example, if I have a custom object, which includes a field of "Subtotal". What I want is when I create or edit this custom object, the "Subtotal" of this object can be automatically added to the Opportunity's "Amount", and I don't need to click another button or custom links (because I think I may forget to do this, and I need the system's autoaction). 
Carl_V1Carl_V1

What was the outcome here?  I would love to know how to route the button to some custom code and then once executed, continue on to the default action?

Regards,

Carl_V

lpadminlpadmin
Any follow-up on this. I am trying to override the "New" button on asset to insert values from related records instead of having to look up those value(s).
sfdcfoxsfdcfox
Assuming you have Enterprise Edition, you can go to Setup | App Setup | Customize | Assets | Buttons and Links | Override (New) to specify an S-Control. First, build your S-Control, which would look like:
<script language="javascript">
window.top.location =
  "{!urlfor( $Action.Asset.New, null, [Account=Account.Name, Account_lkid=Account.Id, Name=Account.Name],true)}"
</script>
Next, go to the Override page and choose the S-Control to use. Finally, enjoy the override. I hope that this helps you resolve your issue.

~ sfdcfox ~