You need to sign in to do that
Don't have an account?
Overriding and extending scontrols from managed packages
I want to create a mechanism where users can easily override or extend code at runtime in scontrols that gets installed as part of a managed package. Since those scontrols cannot be edited like other things in a managed package, I put hooks that call these override functions from another code snippet I want to include. What I want is the ability to put a merge field containing the name of the snipped in an include statement like this:
{!INCLUDE($SControl.{!MyCustomObject.SControlName__c})}
But this doesn’t work. Is there another way to do this or has anybody come up with a way to allow users to extend scontrols that are part of managed packages?
For example, my read only managed package scontrol might look like this. When the page loads, the alert “fooBar” pops up. If the user has supplied a function called “_fooBar” in the scontrol that gets included, then the additional alert “_fooBar” pops up:
MyCustomSControl.scf
Code:
<script src="/soap/ajax/10.0/connection.js"></script> {!INCLUDE($SControl.MyIncludeFunctions)} {!INCLUDE($SControl.{!MyCustomObject.SControlName__c})} <script language="javascript" type="text/javascript"> function initPage() { gCustomSControl = "{!MyCustomObject.SControlName__c}"; //run default method in this script fooBar(); //run override method in another script try { _fooBar(); } catch(ex) { } } function fooBar() { alert(“fooBar”); } </script> <body onload="initPage()"> </body>
And the scontrol that users create and put their custom code in looks like this:
MyCustomSControl_Override.scf
Code:
<script src="/soap/ajax/10.0/connection.js"></script> <script language="javascript" type="text/javascript"> function _fooBar() { alert(“_fooBar”); } </script>
Message Edited by gsickal on 09-19-2007 03:47 PM