Skip to content

Instantly share code, notes, and snippets.

View mmeadow3's full-sized avatar

Mike Meadows mmeadow3

View GitHub Profile
color: #06192e;
text-align: center;
font-weight: 300;
margin: 0;
global class myClass{
webService static String getContextUserName() {
return 'Mike';
}
}
//////////must be a global class & the method must be a webService//////////
///////Execuatable JS on button click/////////////
{!REQUIRESCRIPT("/soap/ajax/38.0/connection.js")}
public class CalloutClass {
@future(callout=true)
public static void makeCallout() {
HttpRequest request = new HttpRequest();
// Set the endpoint URL.
String endpoint = 'http://yourHost/yourService';
request.setEndPoint(endpoint);
// Set the HTTP verb to GET.
request.setMethod('GET');
// Send the HTTP request and get the response.
// Create the account sObject
Account acct = new Account(Name='Acme', Phone='(415)555-1212', NumberOfEmployees=100);
// Insert the account by using DML
insert acct;
EmailManager.apxc file
public class EmailManager {
// Public method
public void sendMail(String address, String subject, String body) {
// Create an email message object
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {address};
mail.setToAddresses(toAddresses);
Hello.vfp
<apex:page>
<h1>My Fancy Site</h1>
<apex:insert name="body"/>
</apex:page>
///////////////newPage.vfp/////////////////
<apex:page sidebar="false" showHeader="false">
<apex:composition template="Hello">
Override the Standard Display for a Page
The Visualforce page you created in Using Standard Controllers can function as a replacement to the standard detail page for an account. You can modify the standard user interface generated by the platform to ensure that your page gets shown instead of the standard page.
1. From the object management settings for accounts, go to Buttons, Links, and Actions.
2. Click Edit next to the View item.
3. For Override With, select Visualforce Page.
4. From the Visualforce Page drop-down list, select accountDisplay.
5. Click Save.
To view go to Accounts Tab, then select a Tab
There’s a lot more to the Ajax and JavaScript support:
• <apex:actionStatus> lets you display the status of an Ajax request—displaying different values depending on whether it’s in-progress or completed.
• <apex:actionSupport> lets you specify the user behavior that triggers an Ajax action for a component. Instead of waiting for an <apex:commandLink> component to be clicked, for example, the Ajax action can be triggered by a simple mouse rollover of a label.
• <apex:actionPoller> specifies a timer that sends an Ajax update request to Force.com according to a time interval that you specify.
• <apex:actionFunction> provides support for invoking controller action methods directly from JavaScript code using an Ajax request.
vfp file
<apex:page controller="ContactsListController">
<apex:form>
<apex:pageBlock title="Contacts List" id="contacts_list">
<!-- Contacts List -->
<apex:pageBlockTable value="{! contacts }" var="ct">
<apex:column value="{! ct.FirstName }"/>
<apex:page>
<!-- Add the static resource to page's <head> -->
<apex:includeScript value="{! $Resource.jQuery }"/>
<!-- A short bit of jQuery to test it's there -->
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery("#message").html("Hello from jQuery!");