Skip to content

Instantly share code, notes, and snippets.

View dashughe's full-sized avatar

Daniel S. Hughes dashughe

  • Advance Local Media, LLC
  • Stone Mountain, GA
View GitHub Profile
@dashughe
dashughe / 1: Create a new REST Endpoint
Created March 15, 2019 22:59 — forked from joshbirk/1: Create a new REST Endpoint
ELEVATE Extra Credit: Custom REST Responses
/*
In the Programmers workbook there is a tutorial on creating a basic REST endpoint using Apex. A common scenario with these
endpoints is needing to enhance the message that gets sent down to client. You can do this easily within Apex by defining
a custom class to use as a response, which will be converted to JSON by the platform.
To complete this extra credit:
1. Create a class from the code below
2. Update the POST and DELETE endpoints to use the RESTMessage class
3. Test the new endpoint with unit test in the next class
*/
@dashughe
dashughe / TaskAfterInsertHandler.java
Created March 15, 2019 22:50 — forked from abhinavguptas/TaskAfterInsertHandler.java
Yet Another Apex Trigger Template
/**
After insert handler on task Sobject
*/
public class TaskAfterInsertHandler implements Triggers.Handler {
public void handle() {
System.debug(LoggingLevel.INFO, 'Post insert handling ' + Trigger.new );
}
}
public with sharing class ChatterUtils {
// makes a simple chatter text post to the specified user from the running user
public static void simpleTextPost(Id userId, String postText) {
ConnectApi.FeedType feedType = ConnectApi.FeedType.UserProfile;
ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
@dashughe
dashughe / AccountController.cls
Created October 11, 2018 18:46 — forked from keirbowden/AccountController.cls
Apex controller from the Lightning Component Wrapper Classes blog post
public with sharing class AccountController
{
@AuraEnabled
public static List<Account> GetAccountNames()
{
return [select id, Name from Account limit 10];
}
@AuraEnabled
public static List<Account> GetAccountDetails(String idListJSONStr)
@dashughe
dashughe / SFCompareController
Created October 6, 2018 12:52 — forked from kiran-machhewar/SFCompareController
Controller for SFCompare.page
/**
* @ApexClass : SFCompareController
* @Description : This provides services to SFCompare page, which can be accessed by js remoting. It provides below services.
* 1. Logging into SF orgs for obtaining session and instance url.
* 2. Fetches code from the SF org.
* */
public class SFCompareController {
/**
* @description : This method does the login to sf orgs and provides session id and
@dashughe
dashughe / !Queueable Apex
Created September 28, 2018 18:53 — forked from scottbcovert/!Queueable Apex
Gist of Centralized Async Handling via Queueable Apex; for accompanying presentation see http://scottbcovert.github.io/queueable-apex NOTE: The following source alone will not compile as it is one piece of a larger Force.com development framework available at https://github.com/scottbcovert/Centralized-Salesforce-Dev-Framework
Gist of Centralized Async Handling via Queueable Apex
For accompanying presentation see http://scottbcovert.github.io/queueable-apex
NOTE: The following source alone will not compile as it is one piece of a larger Force.com development framework available at https://github.com/scottbcovert/Centralized-Salesforce-Dev-Framework
@dashughe
dashughe / VF Page
Created September 27, 2018 22:15 — forked from dancinllama/VF Page
Apex Controller Class
<apex:page controller="CustomSettingController">
<apex:pageMessages id="msgs" />
<apex:form id="theform">
<apex:inputField value="{!cs.Field1__c}" />
<apex:inputField value="{!cs.Field2__c}" />
<apex:commandButton value="{!$Label.CSTab_Save}" action="{!update}" rerender="msgs,theform" />
</apex:form>
</apex:page>
/**
* P2_BatchProcessController
* @description VF controller class for a VF tab
* allowing user to select a batch / schedule apex job
* and execute it immediately
* @author dancinllama
* @date 4/17/2012
*/
public class P2_BatchProcessController {
toolingSoapSForceCom.SessionHeader_element sessionEl = new toolingSoapSForceCom.SessionHeader_element();
sessionEl.sessionId = UserInfo.getSessionId();
toolingSoapSForceCom.SforceService service = new toolingSoapSForceCom.SforceService();
service.SessionHeader = sessionEl;
//service.endpoint_x = //Adjust this to your endpoint, if needed...
toolingSoapSForceCom.ApexCodeCoverageAggregateQueryResult queryResult = service.queryApexCodeCoverageAggregate('Select NumLinesCovered From ApexCodeCoverageAggregate');
System.debug(queryResult);
/**
* @description Simple invocable class (can be called via process or flow). For logging a message or messages to the debug logs.
* @author James Loghry
* @date 8/1/2016
*/
public class InvocableLogger {
@InvocableMethod
public static void log(List<String> messages){
if(messages != null){
for(String message : messages){