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
<apex:page controller="ListAccount">
<div id="content" align="center">
<apex:repeat value="{!theList}" var="acc">
<apex:outputLink value="/apex/forceDetails?id={!acc.id}">
{!acc.Name}<br/><br/>
</apex:outputLink>
</apex:repeat>
</div>
</apex:page>
public with sharing class ListAccount {
public List<Account> theList { get; set; }
public ListAccount()
{
theList=populate();
}
public List<Account> populate()
{
List<account> toReturn = new List<Account>([Select id, name from account limit 20]);
//grabs your SessionId
this.__sfdcSessionId = document.cookie.match(/(^|;\s*)sid=(.+?);/)[2];
//helper function to load scripts on the fly
function loadScript(url, callback) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
var done = false;
script.onload = script.onreadystatechange = function () {
result = sforce.connection.query("Select Name, Id from User limit 10");
records = result.getArray("records");
for (var i=0; i< records.length; i++) {
var record = records[i];
console.log(record.Name + " -- " + record.Id);
}
<apex:page >
<analytics:reportChart reportId="00OV0000000JpEl" size="large"></analytics:reportChart>
</apex:page>
//Copyright - Harshit Pandey
//Http://www.oyecode.com
function loadScript(url, callback) {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
var done = false;
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
<!-- Author - Harshit Pandey -->
<!-- Web : http://www.oyecode.com -->
<apex:page sidebar="false" showHeader="false" standardStylesheets="false">
<apex:includeScript value="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"/>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" media="screen"/>
<style>
.wrapper
{
text-align : center;
}
<apex:page docType="html-5.0" showHeader="false">
<apex:includeScript value="{!URLFOR($Resource.JSForce)}" />
<script>
var conn = new jsforce.Connection({ accessToken: '{!$Api.Session_Id}' });
conn.query('SELECT Id, Name FROM Contact Limit 10', function(err, res) {
if (err) { return console.error(err); }
console.log(res);
});
</script>
</apex:page>
<apex:page showHeader="false" sidebar="false">
<apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js" />
<apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.10/angular.min.js"/>
<apex:includeScript value="{!$Resource.jsForce}" />
<html xmlns:ng="http://angularjs.org" ng-app="hello" lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.no-icons.min.css" rel="stylesheet"/>
<link href="https://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css" rel="stylesheet"/>
<style>
<apex:page docType="html-5.0" showHeader="false">
<apex:includeScript value="{!URLFOR($Resource.JSforce)}" />
<script>
var conn = new jsforce.Connection({ accessToken: '{!$API.Session_Id}' });
conn.query('SELECT Id, Name FROM Account', function(err, res) {
if (err) { return console.error(err); }
console.log(res);
});
</script>
</apex:page>