Skip to content

Instantly share code, notes, and snippets.

View snugsfbay's full-sized avatar

SnugSFBay snugsfbay

View GitHub Profile
@IsTest
public with sharing class UserTest {
// from Trailblazer Community https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000FSHP0SAP
public static String getAppName() {
UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM UserAppInfo WHERE UserId = :UserInfo.getUserId() LIMIT 1];
AppDefinition appDefinition = [SELECT DurableId, Label FROM AppDefinition Where DurableId = :userAppInfo.AppDefinitionId LIMIT 1];
return appDefinition.Label;
}
// failing test to illustrate the problem
String key = 'hgdhdhhdjfh12ehsn';
String secret = 'DNf32sdsj747dhkjd8893jjjdjds7jjk';
//Generating current Unix timestamp (in seconds)
String getTime = string.valueOf(Datetime.Now().getTime()/1000);
String requestInput = key + secret + getTime;
Blob requestBlob = Blob.valueOf(requestInput);
Blob hash = Crypto.generateDigest('MD5', requestBlob);
//Need to convert into hex to generate the equivalent of md5(string) method of PHP.
String key = 'hgdhdhhdjfh12ehsn';
String secret = 'DNf32sdsj747dhkjd8893jjjdjds7jjk';
//Generating current Unix timestamp (in seconds)
String getTime = string.valueOf(Datetime.Now().getTime()/1000);
String requestInput = key + secret + getTime;
Blob requestBlob = Blob.valueOf(requestInput);
Blob hash = Crypto.generateDigest('MD5', requestBlob);
//Need to convert into hex to generate the equivalent of md5(string) method of PHP.
String key = 'hgdhdhhdjfh12ehsn';
String secret = 'DNf32sdsj747dhkjd8893jjjdjds7jjk';
//Generating current Unix timestamp (in seconds)
String getTime = string.valueOf(Datetime.Now().getTime()/1000);
String requestInput = key + secret + getTime;
Blob requestBlob = Blob.valueOf(requestInput);
Blob hash = Crypto.generateDigest('MD5', requestBlob);
//Need to convert into hex to generate the equivalent of md5(string) method of PHP.
<apex:page docType="html-5.0" sidebar="false">
<apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<apex:includeScript value="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"/>
<script>
jQuery(document).ready(function($) {
$.ajax('/services/data/v38.0/limits',
{
beforeSend: function(xhr) {
// Set the OAuth header from the session ID
@snugsfbay
snugsfbay / AddPicklistItemAction.cls
Created September 16, 2018 00:47 — forked from afawcett/AddPicklistItemAction.cls
Prototype Invocable Method wrapping the Salesforce Metadata API to allow management of Picklist Items via Process Builder and Visual Flow
/**
* Copyright (c) 2015, FinancialForce.com, inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
@snugsfbay
snugsfbay / DeveloperConsoleOpenLogById.js
Created August 30, 2018 22:03 — forked from FishOfPrey/DeveloperConsoleOpenLogById.js
Have the Salesforce Developer Console open a debug log by ID
var logId = "07Lc000001OiO8GEAV";
apex.ide.Viewer.open({
id: "l-" + logId,
logId: logId,
Name: "Log " + logId,
xtype: "logviewer",
rawLogSize: 1
});
@snugsfbay
snugsfbay / getDependentPickListsValues.js
Created August 28, 2018 13:11 — forked from bmodeprogrammer/getDependentPickListsValues.js
Get dependent picklist values javascript remoting
/**
* getDependentPicklistOptions
* by Benj Kamm, 2012
* (inspired by http://iwritecrappycode.wordpress.com/2012/02/23/dependent-picklists-in-salesforce-without-metadata-api-or-visualforce/)
* CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/us/)
*
* Build an Object in which keys are valid options for the controlling field
* and values are lists of valid options for the dependent field.
*
* Method: dependent PickListEntry.validFor provides a base64 encoded
@snugsfbay
snugsfbay / Account.csv
Last active February 3, 2018 16:41
Sample Account Data for use with Test.loadData()
Id Name Website Phone BillingStreet BillingCity BillingState BillingPostalCode BillingCountry
1 sForceTest1 http://www.sforcetest1.com (415) 901-7000 The Landmark @ One Market San Francisco CA 94105 US
2 sForceTest2 http://www.sforcetest2.com (415) 901-7000 The Landmark @ One Market Suite 300 San Francisco CA 94105 US
3 sForceTest3 http://www.sforcetest3.com (415) 901-7000 1 Market St San Francisco CA 94105 US