Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Carroll dcarroll

View GitHub Profile
@dcarroll
dcarroll / gist:8427394
Created Jan 14, 2014
Javascript operations for Visualforce Remote Objects. Totally subject to change as this feature is currently in Developer Preview until Summer '14.
View gist:8427394
/* PRE - model declaration on vf page
<apex:remoteObjects>
<apex:remoteObjectModel name="Account" fields="Id,Name" />
</apex:remoteObjects>
*/
/* INSTANCE */
// 1. W/o default properties
var acc = new SObjectModel.Account();
@dcarroll
dcarroll / GoInstant Web RTC Sample
Created Feb 24, 2014
Working sample of using GoInstant Web RTC Chat and Video Widget.
View GoInstant Web RTC Sample
<!-- visStyles Static resource for CSS styles -->
.gi-override {
position: relative;
}
.webrtc-container {
position: relative;
float: left;
width: 559px;
height: 420px;
View TestDataFactory
@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) {
w = createWarehouseLocation('Warehouse 1');
} else {
w = warehouse[0];
View TestInvoiceStatementDeletion
@isTest
private class TestInvoiceStatementDeletion {
static testmethod void TestDeleteInvoiceWithLineItem() {
// Create an invoice with a line item then try to delete it
Invoice__c inv = TestDataFactory.createOneInvoiceStatement(true);
Test.startTest();
Database.DeleteResult result = Database.delete(inv, false);
Test.stopTest();
// Verify invoice with a line item didn't get deleted.
System.assert(!result.isSuccess());
View TestCleanUpBatchClass
@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(
Name='Warehouse 1',
View CleanUpRecords
global class CleanUpRecords implements Database.Batchable<sObject> {
global final String query;
global CleanUpRecords(String q) {
query = q;
}
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(query);
}
View CreateMerchandiseData
public class CreateMerchandiseData {
public static void ClearMerchandiseDataBatch() {
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' +
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)';
CleanUpRecords c = new CleanUpRecords(query);
Database.executeBatch(c);
}
public static void GenerateMerchandiseData() {
View MyScheduler
global class MyScheduler implements Schedulable {
global void execute(SchedulableContext ctx) {
// 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)';
CleanUpRecords c = new CleanUpRecords(query);
Database.executeBatch(c);
}
View _authError.cshtml
@if (ViewBag.ErrorMessage == "AuthorizationRequired")
{
<p>You have to sign-in to @ViewBag.OperationName. Click <a href="@ViewBag.AuthorizationUrl" title="here">here</a> to sign-in.</p>
<p>@ViewBag.ErrorMessage</p>
}