Skip to content

Instantly share code, notes, and snippets.

View Avinava's full-sized avatar

Avi Avinava

View GitHub Profile
@Avinava
Avinava / UserDashboard.page
Created May 26, 2014 10:40
UserDashboard Page
<apex:page sidebar="false" docType="html-5.0" controller="VSDashBoard_Con">
<vs:importvisualstrap />
<script>
function goToDetailPage(recId){
if(typeof sforce != 'undefined' && typeof sforce.one != 'undefined'){
sforce.one.navigateToSObject(recId);
}
else{
window.location.href = '/'+recId;
}
@Avinava
Avinava / UserDashboard.cls
Created May 26, 2014 10:42
UserDashboard Controller
public without sharing class VSDashBoard_Con {
public List<Task> getTasks(){
return [SELECT Id,Subject,Status, ActivityDate FROM Task WHERE ActivityDate = TODAY AND Status != 'Completed' AND Status != 'Deferred'];
}
public List<Case> getCases(){
return [SELECT Id,CaseNumber,Status,Subject, Priority FROM Case WHERE OwnerId=:UserInfo.getUserId() AND isClosed = FALSE];
}
public List<Lead> getLeads(){
return [SELECT Id,Name,Status, CreatedDate FROM Lead WHERE OwnerId=:UserInfo.getUserId() AND IsUnreadByOwner = true];
}
@Avinava
Avinava / SimpleSite.Page
Last active August 29, 2015 14:01
SimpleSite.page
<apex:page showHeader="false" docType="html-5.0" >
<vs:importvisualstrap />
<style>
body{
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.intro{
margin-top:20px;
font-size:140%;
font-weight: 200;
@Avinava
Avinava / RemoteObjects.page
Created June 7, 2014 12:14
Using Salesforce RemoteObjects with JSRender : Create a stateless Table
<apex:page >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
<apex:includeScript value="https://rawgithub.com/BorisMoore/jsrender/master/jsrender.min.js"/>
<apex:remoteObjects >
<!--Name the field you like to query-->
<apex:remoteObjectModel name="Contact" jsShorthand="con" fields="Id,Name,FirstName,LastName,Phone,Email"/>
</apex:remoteObjects>
<script>
//function to invoke the retreive call to query records
@Avinava
Avinava / VSModals.page
Last active August 29, 2015 14:02
Creating new records using Visualstrap Modals. Demo : http://blogforce9dev-developer-edition.ap1.force.com/VSModals
<apex:page controller="VSModals_Con">
<vs:importvisualstrap />
<apex:form >
<vs:visualstrapblock >
<vs:pageheader title="Cases" subtitle="Cases List" icon="file"/>
<vs:panel title="All Cases" type="primary" id="allCases">
<vs:well styleclass="well-sm" style="text-align:center">
<a class="btn btn-success btn-md" onclick="$('#newCase').modal('show');return false;">New Case</a>
</vs:well>
<apex:dataTable value="{!cases}" var="case" styleClass="table table-bordered table-hover">
<apex:page standardController="Case" sidebar="false">
<c:textscanner value="{!Case.Description}"/>
</apex:page>
<c:textscanner value="{!TEXT_TO_SCAN}"/>
@Avinava
Avinava / PBE1KRemoting.page
Created October 21, 2014 10:52
Display more than 1K Records Using JSRemoting with JSRender
<apex:page controller="PBE1KRemoting_Con">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"/>
<apex:includeScript value="https://rawgithub.com/BorisMoore/jsrender/master/jsrender.min.js"/>
<script>
function getContacts(callback){
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.PBE1KRemoting_Con.getContacts}',
function(result, event){
@Avinava
Avinava / customrtf.page
Last active August 29, 2015 14:14
Using customrtf visualforce component in a page
<apex:page standardStylesheets="true" docType="html-5.0" sidebar="false">
<apex:form >
<c:customrtf targetclass="mytextarea" rendered="true" toolbar="full"/>
<apex:inputTextarea styleClass="mytextarea" richText="false"/>
</apex:form>
</apex:page>
@Avinava
Avinava / VFAngularSRemote.page
Created April 3, 2015 11:19
Angular JS & SObject Remote : Part 1 Bringing Data to Page #NoControllers
<apex:page >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"/>
<c:sObjectRemote />
<script>
var vfApp = angular.module('vfApp',[]);
vfApp.controller('vfappController',function($scope){
$scope.accounts = []
$scope.getAccounts = function(){
sObject.query('SELECT Id,Name,Site,Type,Phone FROM Account LIMIT 100',function(result){
$scope.accounts = result;