Skip to content

Instantly share code, notes, and snippets.

View mailtoharshit's full-sized avatar
🤔
Always Curious

Harshit Pandey mailtoharshit

🤔
Always Curious
View GitHub Profile
accounts = [Select ID, Name, BillingState From Account
Where BillingState IN ('CA','NY','FL')];
apex:page controller="RemotingObjectsController">
<script>
/* Declare Javascript Function
function Account(){
this.Id = null;
this.Name = null;
}
var acc1 = new Account();
acc1.Name = 'Texas';
public with sharing class RemotingObjectsController {
@RemoteAction
public static void addAccounts(List<Account> accounts){
insert accounts;
}
}
@mailtoharshit
mailtoharshit / DataUtility
Created August 15, 2012 00:08
UtilityClass Designed to scan all fields of Objects
public class DataUtils {
//pass object name and Id to get all fields for sObject record
public static sObject getObject(string objName, string id) {
String fieldnames = '';
sObject obj;
try {
Map < String, Schema.SObjectType > m = Schema.getGlobalDescribe();
Schema.SObjectType s = m.get(objName);
Schema.DescribeSObjectResult r = s.getDescribe();
@mailtoharshit
mailtoharshit / ActionPlan.cls
Created August 15, 2012 00:16
How to use the method
pageParams = ApexPages.CurrentPage().getParameters();
string theId;
if (pageParams.containsKey('id')) {
theId = pageParams.get('id');
} else {
return null;
}
//now go look up the account using getObject method
@mailtoharshit
mailtoharshit / gist:3420940
Created August 22, 2012 00:38
Encapsulation
public class MyClass()
{
MyClass c = new MyClass();
List<MyClasss> myList = new List<MyClass>();
myList.add(c);
}
private Integer cost;
public Integer getcost() { return cost; }
public void setcost(Integer cost) { this.cost=cost; }
// Variable as Property
public Integer cost { get { return cost; } set { this.cost= cost;}}
//Declaring and using Interface
public interface myInterface {
void doSomething (String thing);
}
public class MyClass implements MyInterface {
public void doSomething(String x);
// SubClass with Method Override
public virtual class myParentClass {
public virtual void dosomething()
{
System.Debug('Something');
}
@mailtoharshit
mailtoharshit / gist:3493987
Created August 28, 2012 00:58
SOQL PolyMorphism
TYPEOF What
WHEN Account THEN Phone, NumberOfEmployees
WHEN Opportunity THEN Amount, CloseDate
WHEN Campaign THEN ExpectedRevenue, StartDate
ELSE Name
END
FROM Event