Skip to content

Instantly share code, notes, and snippets.

View victorabraham's full-sized avatar
💭
...

Victor Abraham victorabraham

💭
...
  • United States
View GitHub Profile
@victorabraham
victorabraham / first gist
Last active January 3, 2020 22:47
My First GIst
This is my first gist. I will add reusable code pieces here, so that code development will be faster. I am targetting to put code related to
# Apex
# Visualforce
# HTML
# Javascript
# jQuery
# CSS
# Java
Testing updatet
@victorabraham
victorabraham / Apex Versioning
Created March 14, 2015 06:36
Version header for apex classes
/****************************************************************************
*Apex Class Name : Name of the class ehre
*Version : 1.0
*Created Date : 26 JAN 2014
*Function : One or two line description the class.
*
*Modification Log:
* Developer Date Description
* ----------------------------------------------------------------------------
* Author Name 01/26/2015 Original Version
@victorabraham
victorabraham / Apex Controller Extension.java
Last active August 29, 2015 14:17
Samples for different types of apex classes
public with sharing class Sample_ControllerExtension {
private sObject mysObject;
// The extension constructor initializes the private member
// variable mysObject by using the getRecord method from the standard
// controller.
public Sample_ControllerExtension(ApexPages.StandardController stdController) {
this.mysObject = (sObject)stdController.getRecord();
}
import java.util.Scanner;
public class Add{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = a+b;
System.out.println(c);
}
@victorabraham
victorabraham / Non-Bulkified Code.java
Last active August 29, 2015 14:19
Code that is not bulkified and contains query inside for loop
//Querying all parent records
for(Parent__c parent: [SELECT Id,name,Status__c FROM Parent__c])
{
if(parent.Status__c =='Completed')
{
//If parent status is Completed querying all child records.
List<child__c> childList = [SELECT Id,Name,Parent__c, child_Status__c FROM Child__c WHERE Parent__c=:parent.id];
for(child__c child:childList)
{
//Changing child status as completed and updating record.
@victorabraham
victorabraham / Bulkified Code.java
Last active August 29, 2015 14:19
This is the bulkified version of Non-Bulkified code
//Declaring initial list to hold list of child records for single update at last
List<child__c> childUpdateList = new List<child__c>();
//Child query is used to return both child and parent records in single query
for(Parent__c parent: [SELECT Id,name,Status__c,(SELECT Id,Name,Parent__c, child_Status__c FROM Child__r)
FROM Parent__c])
{
if(parent.Status__c =='Completed')
{
//If parent status is completed child record status is changed and added into a list
for(child__c child:parent.Child__r)
@victorabraham
victorabraham / Dynamic content in visualforce without controller.html
Last active August 29, 2015 14:19
Showing how to display dynamic content in visualforce page without using controller defined action methods
<apex:page standardcontroller="Account">
<apex:pageblock title="Account Details">
<apex:pageblocksection>
<apex:pageblocksectionitem>{!account.Name}</apex:pageblocksectionitem>
</apex:pageblocksection>
</apex:pageblock>
<apex:pageblock title="Contacts">
<apex:form>
<apex:datatable border="1" cellpadding="4" value="{!account.Contacts}" var="contact">
<apex:column>
@victorabraham
victorabraham / PartnerExample.java
Last active August 29, 2015 14:20
This code sample demonstrates, how to connect to salesforce using partner jar generated from partner WSDL using WSC jar provided by salesforce.
package partner;
import com.sforce.soap.partner.Connector;
import com.sforce.soap.partner.DeleteResult;
import com.sforce.soap.partner.PartnerConnection;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.SaveResult;
import com.sforce.soap.partner.Error;
import com.sforce.soap.partner.sobject.SObject;
import com.sforce.ws.ConnectionException;
@victorabraham
victorabraham / MyAttendance.html
Created August 11, 2015 05:37
Visualforce page to show google chart
<apex:page showheader="false" sidebar="false" controller="myAttendanceController">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<apex:include pageName="header"/>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Status', 'Count'],
['Attended', {!attendedCount}],
@victorabraham
victorabraham / myAttendanceController.java
Last active August 29, 2015 14:27
Controller for showing Google chart in visualforce page
public class myAttendanceController {
public Id contactId;
public Integer attendedCount{get;set;}
public Integer partialCount{get;set;}
public Integer absentCount{get;set;}
public myAttendanceController(){
attendedCount = 0;
partialCount = 0;
absentCount = 0;
User loggedInUser = [Select Id,contactId FROM User WHERE ID=:userinfo.getUserId()];