Skip to content

Instantly share code, notes, and snippets.

@metadaddy
metadaddy / restquery.py
Created November 17, 2011 22:29
Simple query against Force.com REST API in Python
import os
import urllib
import urllib2
import json
import pprint
# Grab credentials from the environment
consumer_key = os.environ['CLIENT_ID']
consumer_secret = os.environ['CLIENT_SECRET']
username = os.environ['USERNAME']
@barelyknown
barelyknown / gist:1369399
Created November 16, 2011 06:09
How do you check if a parent SObject has any children Sobjects in a VisualForce page without a wrapper class?
When looping through a set of Salesforce.com SObjects from a VisualForce page, you may want to test whether the SObject has any children without wrapping the SObjects in a wrapper class. Here's how:
Controller:
Create a property in the controller that is a map of the parent IDs and Boolean flag.
public Map<Id, Boolean> hasChildren {
get {
if (this.hasChildren == null) {
for (Parent__c parent : [select id, (select id from children__r) from parent__c]) {
if (parent.children__r.size() > 0) {
@recalde
recalde / gist:1253878
Created September 30, 2011 14:22
Salesforce showFilePreview
<!-- This is an example of how to use the function -->
<a id="Title_069Q00000006bam" href="javascript:showPreviewDialog('069Q00000006bam', 'Title_069Q00000006bam', 'PDF');">Cover Sheet</a>
<!-- This is the javascript -->
<script type="text/javascript">
function showPreviewDialogForContentDocument(contentDocumentId, titleElementId) {
var query = "SELECT Id, ContentDocumentId, FileType, CreatedDate ";
query += "FROM ContentVersion ";
query += "WHERE ContentDocumentId = '" + contentId + "' ";
@recalde
recalde / Controller.cs
Created July 20, 2011 17:38
Salesforce_JQuery_Remoting
global with sharing class CPPBuilderRob {
public CPPBuilderRob() {
// Remember: @RemoteActions are static, hence controller has no state
}
@RemoteAction
global static CPP_Report_Poller GetReportGroups(string opportunityId) {
// Query from CPP_Report_Request__c
@weakish
weakish / README.md
Created July 27, 2010 19:45
gister -- a #shell script to access http://gist.github.com #gist