You need to sign in to do that
Don't have an account?
yespee
calling VF page from S-Control
Hi All,
I need to override default New lead creation using a wizard created using visual force. However I came to know from Salesforce support I cannot override 'New' button of leads using a custom controller. So I am planning to use an S-control to over ride New button which in turn calls a Visual force page. However I am not sure if this can be done. I would appreciate any kinds inputs. Thanks.
I need to override default New lead creation using a wizard created using visual force. However I came to know from Salesforce support I cannot override 'New' button of leads using a custom controller. So I am planning to use an S-control to over ride New button which in turn calls a Visual force page. However I am not sure if this can be done. I would appreciate any kinds inputs. Thanks.
Scontrols are a deprecated technology and at this point you should stop if you find yourself spending any effort writing new scontrols (or even extending existing ones).
Apex in AJAX
The AJAX toolkit includes built-in support for invoking Apex through anonymous blocks or public webService methods.
To do so, include the following lines in your AJAX code:
<script src="/soap/ajax/14.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/14.0/apex.js" type="text/javascript"></script>
Note: For AJAX buttons, use the alternate forms of these includes.To invoke Apex, use one of the following two methods:
• Execute anonymously via sforce.apex.executeAnonymous (script). This method returns a result similar to the
API's result type, but as a JavaScript structure.
• Use a class WSDL. For example, you can call the following Apex class:
global class myClass {
webService static Id makeContact(String lastName, Account a) {
Contact c = new Contact(LastName = lastName, AccountId = a.Id);
return c.id;
}
}
By using the following JavaScript code:
var account = sforce.sObject("Account");
var id = sforce.apex.execute("myClass","makeContact",{lastName:"Smith",a:account});
The execute method takes primitive data types, sObjects, and lists of primitives or sObjects.
To call a webService method with no parameters, use {} as the third parameter for sforce.apex.execute. For example,
to call the following Apex class:
global class myClass{
webService static String getContextUserName() {
return UserInfo.getFirstName();
}
}
Use the following JavaScript code:
var contextUser = sforce.apex.execute("myClass", "getContextUserName", {});
Note: If a namespace has been defined for your organization, you must include it in the JavaScript code when you
invoke the class. For example, to call the above class, the JavaScript code from above would be rewritten as follows:
var contextUser = sforce.apex.execute("myNamespace.myClass", "getContextUserName",{});
Both examples result in native JavaScript values that represent the return type of the methods. Use the following line to display a popup window with debugging information:
sforce.debug.trace=true;
I think I can work this out using Controller Extension.