This file contains hidden or 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
| /** | |
| * @description: Using Docomotion: create PDF and send via Email from Process Builder using Email Template Developer Name and Form Name | |
| * @documentation: https://www.docomotion.com/support/generating-documents/silent-mode-generating-output-through-an-api/?highlight=API | |
| **/ | |
| public class SendEmailAndPDFAction { | |
| @InvocableMethod( | |
| label='Send Email with PDF' | |
| description = 'Send email with PDF attachment, which takes an Form Name, Email Template Developer Name, who Id and What Id' | |
| ) |
This file contains hidden or 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
| private class CustomExceptionWithConstructor extends Exception { | |
| Private Object obj; | |
| public CustomExceptionWithConstructor(Object obj){ | |
| this.obj = obj; | |
| } | |
| public override String getMessage() { | |
| List<String> args = new String[]{obj.property1, obj.property2}; | |
| return String.format('Custom exception message with multiple arguments: {0} and {1}', args); | |
| } | |
| } |
This file contains hidden or 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
| private class CustomExceptionWithoutConstructor extends Exception { | |
| public override String getMessage() { | |
| List<String> args = new String[]{super.getMessage()}; | |
| return String.format('Your custom message here with one argument: {0}', args); | |
| } | |
| } |
This file contains hidden or 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
| /* | |
| * Having problems with test coverage, this will fix it | |
| */ | |
| public class BigClass { | |
| public static String getValue(String input){ | |
| String output; | |
| output = input; |
This file contains hidden or 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 class SimpleEmailAction { | |
| @InvocableMethod( | |
| label='Simple Email Action' | |
| ) | |
| public static List<Result> sendEmails(List<Request> requests) { | |
| List<Result> results = new List<Result>(); | |
| for(Request request : requests){ |
This file contains hidden or 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 class ChangeRecordTypeAction { | |
| Private static final String RECORD_TYPE_ID = 'RecordTypeId'; | |
| @InvocableMethod( | |
| label = 'Change Object Record Type' | |
| description = 'Change Record Type by Developer Name' | |
| ) | |
| public static List<Response> execute(List<Request> requests) { | |
This file contains hidden or 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 TestClassWithMultipleCallouts { | |
| @isTest | |
| public static void testMethodMultipleCallouts(){ | |
| String contactResource = 'ContactsMock'; | |
| String invoiceResource = 'InvoicesMock'; | |
| StaticResourceCalloutMock contactMock = getStaticResourceCalloutMock(200, contactResource); |
This file contains hidden or 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
| // Useful Apex snippets for formatting date and datetime to String | |
| String value = String.format('{0}T00:00:00', new List<String> {DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0)).format('YYYY-MM-dd')}); | |
| System.debug(value); | |
| // expected output: | |
| // YYYY-MM-ddT00:00:00 |
This file contains hidden or 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 class UpdateGrandChildRecordsAction { | |
| private final static String TARGET = '{0}'; | |
| private final static String REPLACEMENT = '\'\'{0}\'\''; | |
| private final static String FORMAT = 'SELECT Id, {0} FROM {1} WHERE Id = \'\'{2}\'\''; | |
| @InvocableMethod( | |
| label='Update Grand Child Records Action' | |
| description = 'Query child and grand child records and then update grand child records' | |
| ) |
This file contains hidden or 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 class UpdateFieldAction { | |
| @InvocableMethod( | |
| label='Update Field Action' | |
| description = 'Update a field on another object' | |
| ) | |
| public static void updateFields(List<Request> requests) { | |
| for(Request request : requests){ | |
| updateField(request); |