Skip to content

Instantly share code, notes, and snippets.

View TonyRenHK's full-sized avatar
:octocat:
Salesforce

CK Ren TonyRenHK

:octocat:
Salesforce
View GitHub Profile
@TonyRenHK
TonyRenHK / gist:194d73d9a4ecd78f42f61c6f2b6de686
Created October 3, 2016 04:36
HTTP REQUEST SFDC OK VERSION
HttpRequest req = new HttpRequest();
Http http = new Http();
//req.setheader('accept','application/json');
//https://tonyren-my.sharepoint.com/_api/v1.0/me/files/016EQYPSSQZ3I757WQYVALBAADZKWLQDTI/children?expand=thumbnails
req.setEndpoint('callout:Office365NamedCredential2/drive/items/016EQYPSSQZ3I757WQYVALBAADZKWLQDTI/children/Ren.txt/content'); //me/drive/root/children'
req.setheader('accept','application/json');
req.setHeader('Authorization', 'Bearer {!$Credential.OAuthToken}');
req.setHeader('Content-Type', 'text/plain');
String temp= 'data:text/plain;base64,QXBleCBDbGFzc2VzDQoJVW5wYWNrYWdlZA0KCQlBU0lfQ1JNX0NO…FTSV9DUk1fSlBfUmVkaXJlY3RfVGVzdA0KCQlBU0lfQ1JNX0pQX1Rlc3RDbGFzc0hlbHBlcg==';
@TonyRenHK
TonyRenHK / TriggerClass .java
Last active November 15, 2016 05:42
How to send email in TriggerClass in Salesforce
Rectypeid = Schema.SObjectType.Your_Object_API_Name.getRecordTypeInfosByName().get('Record Type').getRecordTypeId();
List<Your_Object_API_Name> terms= [select ownerId,Email__c from Your_Object_API_Name where id in: SID]; // SID :set ID
List <String> ToAddresses = new List <String>();
ID ownerid; // Get Owner ID
boolean Emailexist=false;
for(Your_Object_API_Name poi:terms){
if(poi.Email__c!=null){
ToAddresses.add(poi.Email__c); // Get Email address of Supplier
ownerid=poi.ownerId;
Emailexist=true;
@TonyRenHK
TonyRenHK / TriggerClass2 .java
Created November 15, 2016 05:42
How to send email in TriggerClass in Salesforce
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
string body = 'Hi ';
String[] toAddresses = new String[] {'sksworld10@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setSubject('Test Subject');
mail.setSaveAsActivity(false);
for(OrgWideEmailAddress owa : [select id, Address, DisplayName from OrgWideEmailAddress])
{
if(owa.Address.contains('testuser'))
mail.setOrgWideEmailAddressId(owa.id);
@TonyRenHK
TonyRenHK / SingleEmailMessage.java
Last active October 5, 2017 15:13
How to log issue in SFDC by sending email?
ID userid = UserInfo.getUserId();
User currentUser = [SELECT Id, Email FROM User WHERE Id =:userid];
List <String> ToAddresses = new List <String>();
ToAddresses.add('renchk@foxmail.com');
String subject = 'Issue Log Notification Email';
String body = 'Test' + '\n';
@TonyRenHK
TonyRenHK / log.java
Created November 15, 2016 07:01
How to log issue in SFDC by sending email?
Log__c log= new Log__c( name='log!');
insert log;
Blob b = Blob.valueOf(body);
Attachment attach1= new Attachment();
attach1.ParentId = log.id;
attach1.Name = 'log.txt';
attach1.Body = b;
@TonyRenHK
TonyRenHK / JSForce MeataData Backup.js
Created March 13, 2017 14:10
JSForce MeataData Backup.js
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
loginUrl: 'https://test.salesforce.com', //'https://login.salesforce.com',
version: '36.0'
});
conn.login('youSFDC@Account', 'YourPassword', function(err, res) {
if (err) {
return console.error(err);
@TonyRenHK
TonyRenHK / JSForce Apex Code Backup.js
Last active March 30, 2017 05:23
JSForce Apex Code Backup.js
var jsforce = require('jsforce');
var conn = new jsforce.Connection({
loginUrl: 'https://test.salesforce.com'
});
conn.login('YOURACCOUNT', 'YOURASSWORD', function(err, res) {
if (err) {
return console.error(err);
}
@TonyRenHK
TonyRenHK / retrieve_salesforce_Class_Page_code.js
Last active December 15, 2019 09:36
retrieve salesforce Class/Page code.js
var jsforce = require('jsforce');
var mkdirp = require('mkdirp');
var conn = new jsforce.Connection({
loginUrl: 'https://test.salesforce.com', // if the org is sandbox 'https://test.salesforce.com', if it is Production,please input https://login.salesforce.com'
version: '36.0'
});
var currentdate = new Date();
var datetime = 'YourProjectName_' + String(currentdate.getFullYear()) + String(currentdate.getMonth() + 1) + String(currentdate.getDate()) + '-' + String(currentdate.getHours()) + String(currentdate.getMinutes()) + String(currentdate.getSeconds());
@TonyRenHK
TonyRenHK / Gitshell.sh
Last active November 10, 2017 03:23
Push your code to bitbucket direcly
#!/bin/bash
<<'COMMENT'
run : bash Gitshell.sh
COMMENT
echo "~~~~~~~~~~~~~~~~~Fisrt, Clone your repository~~~~~~~~~~~~~~~~~~"
git clone https://username:Password@bitbucket.org/tonyrenhk/YourCodeRepository.git
@TonyRenHK
TonyRenHK / Report.html
Created August 24, 2017 07:04 — forked from anonymous/Report.html
This is for Jeremy Thompson from Success Community!
<html>
<head>
<script type="text/javascript">
function hideReportCaption(){
var htmlElements = document.getElementsByTagName('h2');
for(var index=0; index<htmlElements.length; index++){
if(htmlElements[index].innerHTML=='Report'){
htmlElements[index].style.display='none';
}
}