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 static int getLineCount( File file ) throws Exception { | |
| try ( LineNumberReader reader = new LineNumberReader( new FileReader( file ) ) ) { | |
| while ( reader.readLine() != null ) {} | |
| return reader.getLineNumber(); | |
| } |
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
| /** | |
| * For any Chatter post that is not a 'LinkPost' then add a FeedAttachment | |
| * that links to system to integrate with, such as a third-party system to capture recommendations. | |
| * | |
| * https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedattachment.htm | |
| * | |
| * Inspired by https://success.salesforce.com/0D53A000036B7Ai | |
| */ | |
| trigger FeedItemTrigger on FeedItem (after insert) { |
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
| /** | |
| * Developed by Doug Ayers (douglascayers.com) | |
| * | |
| * Proof of concept inspired by Matthew Hauck's question | |
| * on the Success Community how to export Enhanced Note to PDF | |
| * https://success.salesforce.com/0D53A000035M8cM | |
| */ | |
| public with sharing class ContentNotePDFController { | |
| public transient String title { get; set; } |
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
| String xml = | |
| '<?xml version="1.0" encoding="UTF-8"?>' + | |
| '<root>' + | |
| ' <SomeNode><![CDATA[<b>contains html tags</b>]]></SomeNode>' + | |
| '</root>'; | |
| // replace CDATA sections with parseable tokens | |
| xml = xml.replaceAll( '<!\\[CDATA\\[', 'XML_CDATA_START' ).replaceAll( ']]>', 'XML_CDATA_END' ); | |
| // we will build up a map of original text and replacement text |
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
| <apex:page standardController="Account"> | |
| <!-- classic attachments related list --> | |
| <apex:relatedList subject="{!account.id}" list="CombinedAttachments" /> | |
| <!-- new salesforce files related list --> | |
| <apex:relatedList subject="{!account.id}" list="AttachedContentDocuments" /> | |
| </apex:page> |
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
| trigger AccountTrigger on Account ( before insert, before update, before delete, | |
| after insert, after update, after delete ) { | |
| AccountTriggerHandler handler = new AccountTriggerHandler(); | |
| if ( Trigger.isBefore && Trigger.isInsert ) { | |
| handler.handleBeforeInsert( Trigger.new ); | |
| } | |
| else if ( Trigger.isBefore && Trigger.isUpdate ) { | |
| handler.handleBeforeUpdate( Trigger.old, Trigger.oldMap, Trigger.new, Trigger.newMap ); |
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
| String header = '--some_random_boundary_string' + '\r\n'; | |
| String separator = '\r\n' + '--some_random_boundary_string' + '\r\n'; | |
| String footer = '\r\n' + '\r\n' + '--some_random_boundary_string--'; | |
| HttpRequest req = new HttpRequest(); | |
| req.setEndpoint( URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v39.0/connect/files/users/me'); | |
| req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId()); | |
| req.setHeader('Content-Type', 'multipart/form-data; boundary=some_random_boundary_string'); | |
| req.setHeader('Accept', 'application/json'); | |
| req.setBody(header + |
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
| String header = '--some_random_boundary_string' + '\r\n'; | |
| String separator = '\r\n' + '--some_random_boundary_string' + '\r\n'; | |
| String footer = '\r\n' + '\r\n' + '--some_random_boundary_string--'; | |
| HttpRequest req = new HttpRequest(); | |
| req.setEndpoint( URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v39.0/connect/batch'); | |
| req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId()); | |
| req.setHeader('Content-Type', 'multipart/form-data; boundary=some_random_boundary_string'); | |
| req.setHeader('Accept', 'application/json'); | |
| req.setBody(header + |
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 with sharing class SampleOpptyController { | |
| public List<Opportunity> opportunities { get; set; } | |
| public SampleOpptyController() { | |
| this.opportunities = queryOpportunities(); | |
| } | |
| private List<Opportunity> queryOpportunities() { | |
| return [ |
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
| // without an ID, simply specify the object to then derive the sobject type | |
| DescribeSObjectResult describeResult = Account.getSObjectType().getDescribe(); | |
| List<String> fieldNames = new List<String>( describeResult.fields.getMap().keySet() ); | |
| String query = | |
| ' SELECT ' + | |
| String.join( fieldNames, ',' ) + | |
| ' FROM ' + | |
| describeResult.getName() |