Skip to content

Instantly share code, notes, and snippets.

View Sunil02kumar's full-sized avatar

Sunil Kumar Sunil02kumar

View GitHub Profile
/*
Details: This class will be used to get access token of other org in order to communicate to other org.
Steps to get Access token using REST API
1. First create Domain name in target org.
2. Create Remote Access (or connected app) in soure org from where we are sending request. System will give Client Id(Consumer key field in Remote access) and
Client secret(Consumer secret field in Remote access).
3. Fetch code by specifying Client Id redirect URL (CallbackUrl specified in remote access) in request. System will prompt only once to login in target org and
will redirect to callback URL.
4. Fetch Code from URL and then request for Access token by specifying code,ClientId, consumer key and redirect url.
5. Parse JSON to get access token and fields returned by target org.
public class RESTAPIPlaygroundController {
public String strSelectedAppId{get;set;}
public String strURI{get;set;}
public String strSelectedMethod{get;set;}
public String strSelectedContentType{get;set;} //JSON or XML
public String strRequestBody{get;set;}
public String strResponse{get;set;}
public String strApexCode{get;set;}
public String strAccessToken{get;set;}
public RESTAPIPlaygroundController(){
/*
Author: Sunil Kumar
Purpose: Uploading and Downloading file from BOX
*/
public class BoxAuthController {
//Variables for Oauth
public String Authcode{get;set;}
public String AccessToken{get;set;}
public String RefreshToken{get;set;}
public String clientid{get;set;}
/*
JSON String:
{
"type":"session",
"id":"d1425e031062455f909740bb770b95a7",
"document":{
"type":"document",
"id":"ab0dc2d377524f44a98fd1476343637e",
"status":"processing",
"name":"",
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- inserting accounts command: process "E:\Data Loader Demo" accountInsert -->
<bean id="accountInsert"
class="com.salesforce.dataloader.process.ProcessRunner"
singleton="false">
<description>inserting Account from csv files</description>
<property name="name" value="accountInsert"/>
<property name="configOverrideMap">
<map>
<apex:page controller="highChartDemoController" sidebar="false" id="pg">
<head>
<apex:includeScript value="{!$Resource.jqueryjs}"/>
<apex:includeScript value="{!$Resource.highChartsjs}"/>
<apex:includeScript value="{!$Resource.exportingjs}"/>
<script type="text/javascript">
$(document).ready(function(){
getDataForHighChart();
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
for(String ss1: schemaMap.keyset()){
if(ss1.equalsignorecase('Contact')){
Schema.SObjectType objToken=schemaMap.get(ss1);
//find details about sobject
Schema.DescribeSObjectResult objDescribe=objToken.getdescribe();
system.debug('*********sobjectAPINamel:'+objDescribe.getName());
system.debug('*********sobjectlabel:'+objDescribe.getlabel());
system.debug('*********sobjectPrefix:'+objDescribe.getKeyPrefix());
system.debug('*********IsCustom sobject:'+objDescribe.IsCustom());
String objectName = 'Lead';
Schema.SObjectType objToken = Schema.getGlobalDescribe().get(objectName);
//find details about sobject
Schema.DescribeSObjectResult objDescribe=objToken.getdescribe();
system.debug('*********sobjectAPINamel:'+objDescribe.getName());
//finding all fields of Lead and generating query dynamically
Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
String query = 'Select ';
string conid='00Qxxxxxxxxxx'; //you can hard code the LeadId or you can pass it through apex method
for(String ss:Fieldmap.keyset()){
public class BatchJobProgressBarController {
private Id batchClassId;
final public String NOT_START = 'not_started';
final public String PROCESSING = 'processing';
final public String FINISHED = 'finished';
public String batchStatus {get;set;}
public Id batchId {get;set;}
public String message {get;set;}
public Integer errornum {get;set;}
public class StatusProgressBarController {
public String selectedObject;
public String selectedField;
public string currentStatus{get;set;}
public list<String> picklistOptions{get;set;}
public StatusProgressBarController(){