Salesforce Developer Workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page showHeader="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false"> | |
<HTML> | |
<HEAD> | |
<script src="{!URLFOR($Resource.jquery)}"></script> | |
<script src="{!URLFOR($Resource.CanJS,'can.jquery.js')}"></script> | |
<script src="{!URLFOR($Resource.bootstrap,'js/bootstrap.js')}"></script> | |
<link rel="stylesheet" href="{!URLFOR($Resource.bootstrap, 'css/bootstrap.css')}"></link> | |
<apex:remoteObjects > | |
<apex:remoteObjectModel name="Contact" jsShorthand="contact" fields="Name,Id,Email"/> | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class TestDataFactory { | |
public static Invoice__c createOneInvoiceStatement( | |
Boolean withLineItem) { | |
// Create Warehouse if one does not exist | |
Warehouse__c w; | |
List<Warehouse__c> warehouse = [SELECT ID from Warehouse__c]; | |
if(warehouse.size() == 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class TestCleanUpBatchClass { | |
static testmethod void test() { | |
// The query used by the batch job. | |
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' + | |
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)'; | |
// Create some test merchandise items to be deleted | |
// by the batch job. | |
Warehouse__c w = new Warehouse__c( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Warehouse if one does not exist | |
Warehouse__c w; | |
List<Warehouse__c> warehouse = [SELECT ID from Warehouse__c]; | |
if(warehouse.size() == 1) { | |
w = new Warehouse__c( | |
Name='Warehouse 1', | |
City__c='San Francisco', | |
Location__Latitude__s=37.7833, | |
Location__Longitude__s=122.4167); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger RestrictInvoiceDeletion on Invoice__c (before delete) { | |
// With each of the invoice statements targeted by the trigger | |
// and that have line items, add an error to prevent them | |
// from being deleted. | |
for (Invoice__c invoice : | |
[SELECT Id | |
FROM Invoice__c | |
WHERE Id IN (SELECT Invoice__c FROM Line_Item__c) AND | |
Id IN :Trigger.old]){ | |
Trigger.oldMap.get(invoice.Id).addError('Cannot delete invoice statement with lineitems'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class ListDetailController { | |
public List<Account> accounts {get; set;} | |
public Account account_detail {get; set;} | |
public Id account_id {get; set;} | |
public Boolean showBack {get; set;} | |
// The extension constructor initializes the private member | |
// variable mysObject by using the getRecord method from the standard | |
// controller. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Invoice__c" extensions="LineItemRemotingExtension" showHeader="false"> | |
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'icons.css')}"/> | |
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'styles.css')}"/> | |
<apex:stylesheet value="{!URLFOR($Resource.OneStarter,'OneStarter.css')}"/> | |
<apex:includeScript value="//code.jquery.com/jquery-1.10.2.min.js" /> | |
<apex:includeScript value="{!URLFOR($Resource.TouchSwipe,'jquery.touchSwipe.min.js')}"/> | |
<apex:includeScript value="{!URLFOR($Resource.OneStarter,'jquery.onestarter.js')}"/> | |
<apex:includeScript value="/canvas/sdk/js/publisher.js"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is an Apex class which calls out to an endpoint to find new merchandise items to be inserted into the system. | |
Before it can be deployed to production, however, it needs a unit test. Since it makes an HTTP callout, however, | |
the unit test will require a mock class. | |
Before you can test the class, you will also need to open a Remote Site to let your Salesforce instance know | |
it is a legitimate site: | |
1. Go to Setup | System Administration | Security Controls | Remote Site Settings. | |
2. Click New. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The Streaming API allows clients to get updates on data changes in near real-time. | |
This is done by keeping an open connection instead repeatedly polling the server, which is much more lightweight. | |
To accomplish this connection, you need a cometD capable client. Luckily, there is a jQuery plugin for this - | |
which makes jQuery in Visualforce an easy way to test out the API. | |
To complete this extra credit: | |
1. Create a Streaming Topic with the following code. | |
2. Include jQuery, the cometD and iCanHas libraries in a Visualforce page. | |
3. Add the necessary JavaScript to connect to the Streaming API |
OlderNewer