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
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 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 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 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 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 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 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 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 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) | |
* Org62 Case 16584902 | |
* GUS W-006274 | |
* | |
* This test creates a file "new document.txt" with contents "Hello World" | |
* in an external data source, such as Google Drive or SharePoint Online. | |
* | |
* Despite being a unit test it has real side effects in the external system. | |
* |
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> | |
<head> | |
<script src="{!$Resource.jquery224}"></script> <!-- https://jquery.com/ --> | |
<script src="{!$Resource.jsforce170}"></script> <!-- https://jsforce.github.io/ --> | |
<script>$j = jQuery.noConflict();</script> | |
</head> | |
<body> | |
<form> |