+ Start a Discussion

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?

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.
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). 

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?



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).
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)}"
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 ~