Community Update: Wiki Pruning, lots of Code Samples and IDE/Workbench/Google news
by Jon Mountjoy on July 15, 2008 at 07:46 AM
It's been far too long since the previous community update. To be fair, I have been doing a fair bit of traveling, mostly on the Tour de Force. Check out our videos from the Dublin event for a taste. In the interim we've released the awesome Google Data API Toolkit, and a new version of the Force.com IDE.
Besides the events, I've been doing a fair bit of blogging and learning about the platform. Right now I'm spending a lot of time pruning the wiki. I hope to make a few improvements, including making things a little easier to find. I've also started to use some of the wiki capabilities such as categories. So for example, here is a page of multimedia items on the wiki. It's not complete yet, but I hope you find it useful. Feel free to ping me about the wiki and any changes you would like to see (or not to see :-) ).
Enjoy the rest of this post, wherein I point to most of the new items that have appeared on developer.force.com recently.
Regards,
Jon
Resources
We have a couple of new resources for you:
- Force.com Toolkit for Google Data APIs - Code the Clouds and integrate Google applications with the Force.com platform
- Workbench 2.0 - a web-based, open source suite of tools to manage your org
- Force.com Developer Library - fact sheets, white papers, tutorials and two full-length books
- Force.com IDE Developer Preview Updated to Summer '08 - as I blogged, there's a new version of the IDE now available
Code
Check out the following new code samples:
- Testing Email Services with Inbound Attachments
- Creating Ideas from Inbound Emails using Email Services
- Visualforce Sample - Dynamic Edit Page
- Visualforce Sample - Consolidated Case History Timeline
- Visualforce Sample - Quote Generation with Pages2PDF
Many thanks to Andrew Waite and Rasmus Mencke for these great samples.
Blogs
Here are some blog posts that caught my eye:
- What the Cloud can Carry - Peter makes the case for enterprise developers to use SaaS and PaaS, not just SMSs
- Workbench: From Idea to 2.0 - Ryan explaining the history behind Workbench
- Intercepting Workflow Outbound Messages in a Ruby Server - I've been experimenting with Workflow and Ruby
- Emailing Visualforce Pages Rendered as PDFs - I've been experimenting with Visualforce and creating PDFs using the new
renderAstag
Multimedia
The following events/screencasts/webinars are now available for your viewing pleasure:
- Master Visualforce in Summer '08 - Move Beyond S-Controls
- The Force.com Platform & Google Data APIs in Action
Upcoming Events
From our event calendar, we have the following events that may interest you:
- Dreamforce '08 - Tour de Force at Dreamforce (November 2-5)
Technorati Tags: salesforce, tourdeforce, visualforce
Test method for Email Services with Attachments
by Rasmus Mencke on June 19, 2008 at 10:02 AM
If you are new to Force.com Email Services and having a hard time writing test methods for your Apex code, this code sample might help you get started.
You can receive email attachments with inbound emails and often you want to build Apex code that uses the attachments. How do I create an inline attachments for the test method?
The example below shows you how you can create a new email message and assign the attachments to it. You can also find the code sample here.
static testMethod void myTestMethod() {
// Create a new email, envelope object and Attachment
Messaging.InboundEmail email = new Messaging.InboundEmail();
Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
Messaging.InboundEmail.BinaryAttachment inAtt = new Messaging.InboundEmail.BinaryAttachment();
email.subject = 'test';
env.fromAddress = 'user@acme.com';
// set the body of the attachment
inAtt.body = blob.valueOf('test');
inAtt.fileName = 'my attachment name';
inAtt.mimeTypeSubType = 'plain/txt';
email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] {inAtt };
// call the class and test it with the data in the testMethod
myTestObj emailServiceObj = new myTestObj();
emailServiceObj.handleInboundEmail(email, env );
}
Create Ideas from Emails
by Rasmus Mencke on June 19, 2008 at 09:55 AM
I have built an example of how you can use Salesforce Ideas and create new ideas from emails. Using Force.com Email Services to allow people to send emails and convert the emails into new Ideas.
Taking the subject line as the title of the Idea and use the body of the email as the content for the Idea.
The main class for creating the Email Services is below.
Global class IdeasSample implements Messaging.inboundEmailHandler{
Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env ) {
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
// Create the new Idea from the incoming email
createIdea(email.subject, email.plainTextBody, env.fromAddress);
// Set the result to true, no need to send an email back to the user
// with an error message
result.success = true;
// Return the result for the Apex Email Service
return result;
}Creating the Idea takes the subject, text body of the email and the from email address as arguments
public static Idea[] createIdea(String IdeaTitle, String ideaBody, String fromEmail) {
// instance of a new Idea
Idea[] newIdea = new Idea[0];
// create a new Idea
newIdea.add(new Idea(Body = ideaBody,
Title = IdeaTitle));
insert newIdea;
sendEmail(fromEmail,newIdea);
return newIdea;
} To see the full code sample check this out
Community Update: Intros, Tour de Force, Visualforce
by Jon Mountjoy on May 30, 2008 at 05:03 AM
I'm a new member of the force.com team, and I'll be working here as the community manager and editor-in-chief of developer.force.com. As a result, I hope to be touching base with a lot of you developers, ISVs and admins out there, as well our internal salesforce.com employees. I'll also be working at developing our blog and content strategies, infrastructure and more. There's a lot to do, and I'm keen to help our thriving community grow even bigger. Feel free to ping me at any time about the community, with any suggestions, complaints or comments (jmountjoy at salesforce dot com) or join me on Twitter or other data streams.
I will be producing a community update like this every week or two, highlighting forthcoming events (check out the awesome Tour de Force website with new events in the USA, Ireland and Japan), community members (see Anshu), webinars (Move Beyond S-Controls), interesting board threads, things that catch my eye (like the Dreamforce Session Idea site), external sites (Simon, Joe, Steve and many more) and so on, so please stay tuned.
Regards,
Jon
Resources
We have a couple of new resources for you:
- A short Visualforce Components Demonstration by Adam Gross shows off some of the capabilities found in Visualforce Components. This is going to big: reusable, modular, user interface components. I need to create a directory listing components that we can start finding them all. Done!
- A new Visualforce resource page recently went live, pointing to reference material, tutorials and webinars to get you up to speed on the technology.
Blogs
In the blogs, I'd like to welcome new blogger Anshu Sharma. Anshu blogged about being In India, with Force(.com)!, and some of the questions he encountered during a talk he gave on PaaS and Force.com.
Also in the blogs, Ron Hess tells us about Coding The Cloud at Google's I/O Event, where he's presenting on integrating force.com apps with Google GData interfaces. I'm also keen to see how our developers use the new Google Earth API. We've seen plenty of Google Maps mashups - now how can we use Google Earth too?
Finally, Peter Coffee has some interesting thoughts on what it means to be Disconnected. He makes the point that "..it's not the problem of any single technology provider (or even any particular subset of the tech provider ecosystem) to solve the problem of staying up and running even if your public network link is intermittent."
Upcoming Events
From our event calendar, we have the following events that may interest you:
- Tour de Force - in USA, Ireland and Japan (June/July)
- Webinar: Mastering Visualforce, Move Beyond S-Controls - (June 18)
- eBay Developer Conference - where we're keynoting and presenting (June 16)
- DreamForce '08 - suggest a session for the conference too! (November 2-5)
Education Services
Education services have two upcoming courses:
- FDC-320 Force.com: Application Laboratory - in various cities in the US (June/July)
- FDC-320 Force.com: Application Laboratory - in London, UK (June)
Technorati Tags: salesforce, tourdeforce, visualforce
Coding The Cloud at Google's I/O Event
by Ron Hess on May 16, 2008 at 07:11 AM
Ever since the introduction of Apex SOA / Callouts last spring, I've wanted to revisit the GData integration sample code that was originally built using JavaScript. Now with the upcoming Google I/O developer event in San Francisco on our speaking calendar, I am putting the finishing touches on a great Apex to Google demo. In my Google I/O presentation, I will explain and demonstrate how you can quickly achieve a custom integration between your force.com platform apps and Google GData interfaces. Yes, Apex speaks REST, and you can learn how. Salesforce.com is honored to be one of the companies that Google has invited to speak at its upcoming, first-of-its-kind, developer gathering. Bing Yang from our R&D team will be speaking there too in another GData session that will cover authentication mechanisms.
With the introduction of Salesforce for Google Apps, several integrations are already available out-of-the-box. However for a Force.com developer, it's just the start. What if you want to integrate your platform app with Google Spreadsheets or Calendars? Well, the good news is that there are plenty of features in both force.com and Google to build a robust and high performance GData integration that is custom to your force.com app.
This is what CODA has done in CODA2go, their new force.com financials app -- they include a feature to export your invoices into Google spreadsheets where you can edit them in a normal sheet format.
If you haven't already registered for I/O, please check out the sessions and speakers and get ready for a deep dive into various Google developer technologies, with a bit of force.com platform thrown in. Stop by the demo area and say hello!
Updating a Classic
by Ron Hess on April 30, 2008 at 10:17 PM
With all the excitement around Tour de Force, and the upcoming trip to London for Dreamforce Europe, I wanted make sure you didn't miss a cool update to a classic AppExchange app called PrintAnything. A while back I wrote a blog post that covered how to integrate PrintAnything with Google Docs to generate PDF output. Now, with the updated version of PrintAnything called Astitch Document Generator, you can perform this directly using the service provided by Astitch.net.
There are two things I like about this app, first off it's free and secondly it's a technically deep product, lots of customizations are possible once you learn how to utilize XSLT templates and construct the required SOQL queries. Not a task for everyone, but if XSLT is exciting or even something you would like to learn, check out this app!
Force.com Email Services sample code for how to unsubscribe from emails
by Rasmus Mencke on February 19, 2008 at 02:36 PM
Most companies send out marketing emails to their customers and prospects, and need a way to allow them to unsubscribe from your email messages. This sample code shows how you can write Force.com Email Services to process unsubscribe requests from the email recipients.
- The code will search in the subject line for the word “unsubscribe”
- If the words is found, I will first find all contacts who matches the from Email Address and set the HasOptedOutOfEmail to true
- Then I search though the Leads and look for the same email address and updates the HasOptedOutOfEmail to true as well
- The code then returns true and exists
Force.com Email Services
by Rasmus Mencke on January 29, 2008 at 05:23 PM
Force.com Email Services or email to Apex is now generally available for all customers who have Apex Code enabled. Email Services lets you define email addresses, which can process Apex code. Send emails to Salesforce and process them with Apex code to create and update data from inbound emails.
The sample code shows you how an email can be
used to create new tasks for a contact record with a matching email
address.
What is new in the Spring’08 release
- Must implement the Messaging interface
- Implemented a namespace “Messaging”
- Additional input parameter “Messaging. InboundEnvelope”
- New and improved security model
- Uses Email Authentication protocols (SPF, SenderId, DomainKeys) to secure the email addresses
Note: For people who were using the previous Developer Preview version.
Your code will not work in the Spring '08 release, until you change it to the new format, for more detailed information on the changes, please see the Spring '08 release notes.
WebGuild Web 2.0 Conference
by Dave Carroll on January 22, 2008 at 07:08 PM
The WebGuild Web 2.0 Conference and Expo is next Tuesday, January 29th in Santa Clara. I'll be participating in a panel discussion called "Building the Mashable Web" with Kevin Hackman of Tibco. Kevin created General Interface, an AJAX platform, before AJAX became a buzz word.
The moderator for the discussion is Ismael Ghalimi, the CEO of Intalio, an almost 10 year old Open Source BPMS (Business Process Managment System). He is a true veteran of Silicon Valley and serves as an Advisory Board Member on several contemporary statups.
This should be a fun and interesting session and I hope to see you there.
Developing the Cloud at DevX
by Dave Carroll on January 21, 2008 at 02:42 PM
Head on over to DevX to read a Special Report feature on SaaS and Building On-Demand Applications in the Cloud. This report consists of five articles around building applications for On-Demand including Force.com, Amazon and Bungee Labs.
I'd like to especially thank E.J. Wilburn of CRMFusion for contributing a great article and tutorial for this Report. You can read his article Getting SaaS-y with Apex and VisualForce.
Using Browser Technologies in Visualforce - Part 1
by Dave Carroll on November 7, 2007 at 04:24 PM
Since the announcement of Visualforce (VF) at Dreamforce in September, I have received a lot of questions about various browser technologies and how they fit into the VF strategy. The questions range from "are we going to abandon support for AJAX and Flex?" to "When should I use AJAX and Flex and when should I use VF components?".
Read the full wiki article here.
Get Your Winter '08 Developer Guides
by Andrea Leszek on October 22, 2007 at 10:52 AM
Get a head start on Winter '08 with the latest Force.com Developer Guides:
- Visualforce Developer's Guide - in HTML or PDF
- Apex Developer's Guide - in HTML or PDF (formerly known as the Apex Code Language Reference)
- including an AppExchange package of code samples
- Force.com Web Services API Developer's Guide Version 11.0
- including the Winter '08 API Release Notes
- AJAX Toolkit Developer's Guide Version 11.0
For details about what's new for Visualforce and Apex, see the Winter '08 Release Notes. And check out the Documentation page on the ADN wiki for all your developer doc needs.
Building Offline Salesforce Applications with Google Gears and Google Web Toolkit
by Kavindra Patel on September 10, 2007 at 08:55 AM
Folks,
Here is great a article on building offline salesforce apps. Yes, you heard it right, offline salesforce apps!
Imagine your Salesforce.com web application user meets a client at a coffee shop, flips open their laptop, and notices that there's no internet connection. This
doesn't stop them connecting to your Salesforce.com web application and
viewing account and contact information though, much to their client's
obvious surprise. With the use of Google Gears and Google Web Toolkit you now can make any
on-demand application work offline. Read all about it in this
article and download the sample code to get started.
Also, this year, we have Google in the breakout sessions and the Dev Lounge at Developers@Dreamforce '07. It is not too late to join us.
Cheers!
The ADN Team
RTFM*... And Tell Us What You Think!
by Andrea Leszek on August 14, 2007 at 09:48 PM
Ever read a piece of documentation and think "Wow, that was great!" or "That wasn't exactly right. I wish they would fix that."? It can be pretty frustrating to use documentation that's inaccurate and have no way to let anyone know. The salesforce.com Documentation team is right there with you.
With this latest release of the Web Services API Developer's Guide, every page now has a feedback form so you can submit changes, corrections, and, of course, compliments(!) directly to the folks who write it. Just scroll down to the bottom of any API doc page, click the link, and submit your feedback. Giving us your contact info is completely optional.
But will your feedback go into the Internet void, never to be seen again? No, absolutely not! All feedback goes directly to the salesforce.com Documentation team. Although we won’t always be able to give a personal response, we're committed to fixing any issues, errors, or bugs as quickly as we can.
Customer satisfaction is the hallmark of salesforce.com's success. We take that seriously, especially in the documentation we provide. If you're not satisfied, we want to make it right. And of course, if you like the docs, we wouldn't mind hearing that too!
*Read The Friendly Manual
Why Flex/AIR Developers should care about Apex Platform
by Dave Carroll on July 11, 2007 at 10:29 AM
Flex and Flash have been used to create dynamic and rich internet applications for several years. The fact that you can create compelling, user friendly commercial applications using Adobe's Flex and Flash technologies is undisputed.
But what if you have a great idea for a commercial, multi-user, highly reliable and available business application? Your application would need to be scalable, reliable, and require world class data center services. So, what are your options at this point? First, you could spend a lot of money and a lot of time creating the infrastructure to support your application. Or, more interestingly, you could leverage the salesforce.com platform, that already has the reliability, scalability, and security built into it.
Combining Adobe's Flex technology deployed to the desktop using the Adobe Integrated Runtime (AIR) with the salesforce.com on-demand platform using the Flex Toolkit for Apex provides a fast track to RIA success.
Continue reading "Why Flex/AIR Developers should care about Apex Platform" »
AJAX Proxy - Mashup Third Party Web Services
by Dave Carroll on July 6, 2007 at 09:16 AM
For the last couple years we've been providing great AJAX based options for developing on the salesforce.com Platform. While this has provided a significant ability to create interesting and useful mashups, developers inevitably run up against the Same Origin Policy in the browser security implementation that limits the third party web services that can be mashed up.
We recently released a part of Salesforce SOA for general availability that provides a solution for this problem. Salesforce SOA is actually two technologies, one that allows the consumption of 3rd party web services from the plaform using Apex Code, and one that allows the consumption of 3rd party web services from the client or S-Controls. It is the client technology, AJAX Proxy, that is currently available.
To understand how to use AJAX Proxy check out the tutorial/code sample. For a more involved sample of mashing up Google Calendar using AJAX Proxy go here.
Using Adobe Flex to Build Rich On-Demand App - Follow Up
by Dave Carroll on June 27, 2007 at 12:56 PM
Thanks to all of you who attended the webinar today. We really enjoyed presenting the exciting combination of Adobe Flex/AIR and the salesforce.com platform. I have created a wiki page to contain the code that I demonstrated today.
The sample is simplistic but illustrates some key concepts when using Flex and the Flex Toolkit for Apex. First is the data binding piece. Flex natively supports collections as the data source for data binding. The Flex Toolkit for Apex returns a collection as the result of a query. This makes simple binding extremely easy.
Another concept that is key, but was not illustrated in the webinar, is the ability to create your own components based on (inheriting from) the standard SDK components. This makes modifying the behavior of items like the Grid component very easy. This is especially true when compared to other "traditional" RIA technologies.
Grab the trial version of Flex Builder, or better yet, take advantage of the discount code presented in the webinar, and try some of this stuff out yourself. I am confident that you will not only find it useful but fun as well.
Template Folders in the API
by Rasmus Mencke on June 26, 2007 at 09:16 AM
If you are working with templates and template folders, you might have run into challenges around displaying folder names for templates in the personal and public folders.
The API does not return folder name for Personal or Public folders in the API. The personal folder is represented by the user id and the public folder is represented by the org id.
To decode the folders into the personal and public folder names you can use this example code from the ADN Wiki http://wiki.apexdevnet.com/index.php/Get_Template_Folder_Names
Example when returning folders from the API before:
After decoding the folder names from into personal and public folders, you will be able to find and scroll through your folders.
Tutorial: Creating Flex Salesforce Mashups
by Kavindra Patel on April 26, 2007 at 10:34 AM
You will be thrilled about the Flex Toolkit for Apex. You can quickly build rich applications in Flex using the popular Flex Builder Eclipse toolkit to layout widgets and unique graphics, then connect the app to the Salesforce data. Here is the steps to get started:
Step 1: Watch a quick demo
Step 2: Read the tutorial
Step 3: Download the Flex Toolkit for Apex (beta)
Step 4: Create your killer app.
Also, this year, we have Adobe experts in the breakout sessions and the Dev Lounge at Developers@Dreamforce '07. It is not too late to join us.
Cheers!
The ADN Team
Pushing Data from an External System using Upsert()
by Peter Dapkus on April 9, 2007 at 09:46 PM
Upsert() is a hidden gem in the API. Our goal for upsert() was to allow you to push data from an external database into Salesforce.com using without having your external system know anything about salesforce.com IDs. Conceptually, we wanted to let you switch from sending updates that looked like this:
to updates that looked like this:
There are three key problems to solve to enable this :
- We have to avoid having you choose between create() or update(), since you don't know if the record already exists
- We have to help you match the record from the external database to one within salesforce.com using the external system's IDs
- We have to help you setup the relationship from this record to other records, since this traditionally requires that you know the saleforce.com record to which you want a relationship.
We addressed the first two of these in our 7.0 API. We introduced the new verb, upsert(), so that we had a verb that would just do the right thing (insert or update). We also allowed you to designate certain fields as external ID fields. These fields allow salesforce.com to hold the ID from the external system so that we can do the matching accurately and efficiently. The upsert() method takes an addtional parameter over update, specifically the name of the external ID field to use for matching for the call.
In our 8.0 API, we tackled the third. Our 8.0 API added the concept of relationships to our API. The changes to our API's data model gave us a flexible way to express the relationship between objects using an external ID. The new data model allows parent objects to be embedded in an object. We use this capability to allow you to specify both the name of the parent object's external ID field and to include the external system's ID value.
If you have custom fields with the external ID property set on both Account (DUNS__c) and on User (EmployeeID__c), this is what it looks like to use upsert() via our AJAX toolkit:
// Create a record to be upserted using DUNS number
var account = new sforce.SObject("Account");
account.Name = "ACME Widgets";
account.DUNS__c = "1234567";
account.Phone = "2837484894";
// Set the relationship to an Owner (User) using Employee ID
// we use a nested User object with an external ID field set
// rather than just setting an ID field on account
var owner = new sforce.SObject("User");
owner.EmployeeID__c = "123456";
account.Owner = owner;
// upsert call using DUNS__C as external ID
var result = sforce.connection.upsert("DUNS__c", [account]);
One caveat: When you nest a parent object, you can only set one external ID field on it. In other words, you cannot use upsert to do a cascaded update to the parent.
This may look like a lot of code, but it does a lot! We were able to do the complete operation with a single call to the API. Without upsert, this would have required two additional calls to get salesforce.com IDs on Account and User and some client logic to choose between create() and update(). Fewer API calls also means fewer network round trips The result is less code, less client logic, and much higher performance!
Introducing the AJAX Toolkit 8.0
by Peter Dapkus on February 9, 2007 at 05:19 PM
In Winter '07, we've released the first fully supported version of our popular AJAX Toolkit. The new toolkit is a ground up rewrite of the original toolkit -- the new toolkit provides a streamlined API and as much as a 5x performance boost over the original.
Incorporating the new toolkit into s-controls couldn't be easier -- we're hosting the toolkit directly on our production servers, so all you need to do to include the toolkit is add a simple script element:
<script type="text/javascript" src="/soap/ajax/8.0/connection.js"></script>
In an s-control in the context of a user's web session, we will automatically set the toolkit up with a current Session ID and the proper serverURL -- no need to call login(). Once the toolkit is loaded, you can start making calls against the API directly. Here's a code snippet that will query a set of accounts and loop over them, printing the Account name:
var result = sforce.connection.query("select Name from account"+
" where BillingState in ('CA', 'OR', 'WA')")
result.records.forEach(function(account) { print(account.Name) })
One notable difference from the original toolkit is that you can now access fields directly, without using a getter (i.e. no account.get("Name")) -- which makes the code more compact and easy to read. The setters/getters are still there, of course, if you'd rather use those.
We have a complete set of docs for the new toolkit available. We've also put together a guide for those who'd like to port their s-controls from the Beta version. You can find that under Migrating from the Beta AJAX Toolkit.
Over at the AppExchange, we also already have some nice contributions that build on or extend the AJAX Toolkit:
- AJAX Tools - This package contains a collection of tools for developers working with AJAX toolkit to build s-controls. Included in the package are: A syntax-highlighting editor that can load/save s-controls directly from your account at salesforce.com; extensive code samples for the toolkit, dojo, and the UI in a handy code browser; a javascript shell with completion and input history -- very handy for trying commands against the API; and a SOQL Explorer for browsing your data schema and building SOQL queries. A MUST for every Developer Edition account.
- Scripting Toolkit - This offering lets you use the AJAX Toolkit and javascript as a scripting language from Windows. With this package, you can write and run batch scripts to do common and/or bulk tasks using the salesforce.com API using nothing more than a simple text editor (no IDE, no compiling, etc). Very Handy!
If you have other examples of the AJAX toolkit in action, let's see 'em -- post them to the comments section below.
More Gifts of SOQL
by Adam Gross on January 31, 2007 at 11:57 AM
Even for those lucky enough to spend all day with the Apex platform, some of the gems of the new SOQL syntax in the 8.0 API continue to delight and amaze. Today's discovery (for me, at least) is the DATE syntax available in working with timestamps.
Date math is one of those painful and tricky things, that often involves delving into the calendar APIs of your favorite language. Imagine trying to get a list of all the new members of a campaign for the previous day - before, you'd need to construct a date, roll it back to yesterday, make sure you handled any tricky year/month boundaries, and dynamically insert the date in your SOQL as "createddate > 1999-01-01T23:01:01Z and createddate < 1999-01-02T23:01:01Z" (or something close).
Now, that SOQL statement is as simple as "createddate = YESTERDAY".
Wow!
You, can even do something like 'createddate = LAST_N_DAYS:4" to get the preceding 4 days of data.
Full details are here. Another great reason to start using API 8.0, as if relationships weren't enough!
Apex Explorer Is Back
by Dave Carroll on January 25, 2007 at 04:56 PM
It's been a pretty hectic month or so, but I've finally published the latest version of the sforce, er, Apex Explorer. There is more that I want to put into it, but, due to popular demand, I've packaged up a cut that supports SOQL-R and has all the new describe meta-data in the schema browser.
As always, the source is included so feel free to look under the covers.
Cheers
Maintaining Context in Asynchronous Ajax Calls
by Dave Carroll on January 11, 2007 at 12:27 PM
Managing context during the execution of a callback function froam an asynchronous Javascript call can get a bit hairy at times. This is because when you execute your Apex AJAX method you can only specify the function that gets called without arguments. One example would be to pass an element to the callback that will display the data returned from the function. Perhaps I have two tables that I would like to render asynchronously and the only difference is the destination of the data. What would be optimal is to be able to pass the table element to my callback function, thereby avoiding duplicate code from having to similar callbacks that only differ by name.
This is possible in the new Ajax Toolkit for Winter07. The callback argument can be a structure that contains multiple useful values. The one that will help us in this case is the "source" value. Our source value is essentially a set of key-value pairs. When used as part of the callback argument, this source structure is passed, without modification, to the callback function.
Here is a sample. In the new toolkit, you can specify a callback for failure and for success. In either case, the "source" value is returned to our callback. The result contains the results of the API call.
var result =
sforce.connection.query("Select Name,Id from User",
{
onSuccess : renderUser,
onFailure : handleError,
source : {tableName : document.getElementById("leftUserTable"), background : "red"}
});
function renderUser(result, source)
{
log(source.newValue);
var records =
result.getArray("records");
for (var i=0;
i<records.length; i++) {
var record =
records[i];
log(record.Name +
" -- " + record.Id);
}
}
function handlerError(error, source) {
log("oops something
went wrong " + error);
}
Hopefully, using the new callback structure and, in particular, the source value will ease the transition into asynchronous Javascript development.
Cheers
SOQL Relationships in Apex API 8.0
by Peter Dapkus on January 4, 2007 at 08:34 PM
The most popular API feature request we have ever gotten has been that we extend SOQL to allow it to return related objects along with the object being queried -- for example, to allow a single query to return a set of accounts and the set of related contacts and opportunities for each account. I'm happy to say, we're delivering on this request with SOQL Relationships in Winter '07!
In Winter '07, the SOQL syntax has been extended to allow queries to traverse relationships and return related objects in a single API call. The relationships are the ones that you have defined in the application via a Lookup Relationship or a Master-Detail relationship.
The simplest case is where you traverse from queries target object to one or more of it's parent objects. You can use parent (or many-to-one) relationships like this:
SELECT Id, Name, StageName, Owner.Name, Account.Id, Account.Name
FROM Opportunity WHERE Account.Industry = 'Banking'
This query uses parent relationships in two ways. First, it filters Opportunities based on the industry of the parent Account in the WHERE clause. Second, it returns data from parent objects -- the Name of the Opportunity's Owner, and the Id and Name of the parent Account. Prior to relationships, this would have taken no fewer than three queries and some client side processing to produce equivalent results.
You can also use SOQL Relationships to return child objects too:
SELECT Id, Name, (SELECT Name, Phone FROM Contacts WHERE MailingState = 'CA') FROM Account
Notice the sub-query on Contacts in the field list? This query of accounts returns the Id and Name of each account, and all the contacts with MailingState equal to "CA" for each account.
Relationships vs. Joins
One frequent question is: How are SOQL Relationships different than SQL JOINS? SOQL Relationships have a lot in common with SQL Joins, but there are some key differences.
First, Relationships are defined in your data model, not in your queries. The relationships you can use in queries are the ones you've defined between your objects in salesforce.com. You don't need to define the relationship in the query itself. We hope this makes the query syntax simpler and easier to master.
Second, the results you get back are object hierarchies, not tables. For example, if you ask for a set of accounts and all the child contacts for each of those accounts, you get back a set of accounts (one object per unique account) with the contacts for each account nested inside the account object.
Finally, one thing that you can do with SQL JOINs that you cannot do with SOQL Relationships is exception reporting (i.e. find me all the accounts with no open opportunities). SOQL can get you all the accounts and the contacts for each, but the client application will still be responsible for finding the "exception" accounts. If you think this is an something SOQL needs, please vote for the idea over at the Idea Exchange.
For a more complete discussion of the syntax, how the results our returned, and some of the finer points of using Relationships, I invite you to check out our API 8.0 documents; the SOQL Relationships documentation is here.
I should also mentioned that we're also adding support for relationships to Apex Explorer 8.0 (fka sforce Explorer) -- look for it's release next week. Also, our new AJAX toolkit will support relationships right out of the box.
As you can probably see, this greatly increases the power of SOQL and our API. One of our early developers reported being able to rebuild a custom detail page that previously required 7 queries with a single query and a lot less client-side code. I look forward to hearing back from all of you -- please share your experiences and let us know what you think of this new functionality and syntax!
Aloha,
Pete
Winter 07 API & AJAX Docs
by Ron Hess on December 18, 2006 at 10:20 AM
As Peter mentioned earlier, the new docs are out, on the ADN doc page. If you've been using the Beta AJAX toolkit, please check the guide to migrating your AJAX code, found at the end of the AJAX Doc. The Beta AJAX code will continue to run your existing S-Controls, but the new toolkit will provide a performance improvement, so check it out. The changes and additions to the API are listed here, and the complete 8.0 API doc is here. The entire Winter 07 release notes PDF is also available for your holiday reading.
What's in API 8.0?
by Peter Dapkus on December 7, 2006 at 11:27 AM
With our Winter '07 just around the corner, I am beginning a series of posts to highlight some of the great new features in our 8.0 API.
For this release, we have made an effort to incorporate all of the most commonly requested enhancements. The result is our biggest, most ambitious release of the API ever! Here are some of the highlights:
- SOQL Relationships – Now you can create SOQL queries that filter on and retrieve data from related records in a single call -- retrieve an account and all its related opportunities and contacts with a single query. This is an object-oriented answer to SQL Joins for SOQL.
- AJAX Toolkit – Now you can access the API from javascript easily using our high performance AJAX toolkit. This ground-up rewrite is 3-5x faster than our beta AJAX toolkit and supports synchronous and asynchronous calls.
- Upsert with Relationships – Enhanced upsert call allows you to insert or update records and their relationships using foreign IDs from an external system. Integrating with a legacy system has never been easier!
- ConnectOut - ConnectOut allows you to use workflow to trigger outbound Web Service calls to and SOAP endpoint you define. With this, you receive near real-time notifications of changes and additions to your data at Salesforce.com without polling!
- Merge API – The merge functionality previously only available via the UI is now available via the API. This enables customers to provide their own logic to efficiently and reliably merge Accounts, Contacts, and Leads.
- SOQL Enhancements – SOQL now has support for ORDER BY, LIMIT, IN, and count(), familiar to SQL developers. toLabel() and convertCurrrency() methods allow queries to retrieve translated labels and converted currencies.
- SOSL Enhancements – As with SOQL, SOSL now has support for ORDER BY, count(), toLabel() and convertCurrrency(). SOSL Queries can now also return data from parent records via relationships (e.g. Account name for a Contact).
- Updated Apex Explorer and Data Loader - Our popular API clients have been updated to take advantage of the new features in the 8.0 API.
- Custom Validation and Unique Fields– New features in the application such as Custom Validation rules on fields and Unique field constraints are also enforced via the API
- New Objects, New Metadata – We now expose more of our standard objects via the API (e.g. Workflow Approvals, EmailTemplate) and expose more metadata.
I will be diving into to each of these features in subsequent posts. Stay tuned!
In the mean time, if you want to learn more about what the new release, keep an eye on ADN. We'll be publishing release notes and 8.0 documentation in the next couple of days.
Let us know what you think!
Cocoa gets some love
by Simon Fell on November 22, 2006 at 01:07 PM
I recently wrote an Objective-C / Cocoa library for accessing the Salesforce.com API called zkSforce, which I used to build SoqlXplorer and SfCubed. It's released it under the uber liberal open source MIT license, share & enjoy.
Developer Tool: File Watcher
by PK on September 19, 2006 at 11:19 PM
From one of our Sales Engineers, Steve Buikhuizen, comes a great development tool!
These tools allow you to edit fields, documents and s-controls using any editor. When you save locally, the watcher will save the file back to Salesforce. Simple.
Note: These tools are not officially supported by Salesforce.com
soql Xplorer
by Simon Fell on September 5, 2006 at 07:00 PM
One for the Mac folks, I put together a native OSX app for testing out SOQL queries, examining the describe details etc, called soql Xplorer. enjoy!
AJAX Debugging in Firefox
by Dave Carroll on January 24, 2006 at 09:16 AM
If you don't like to use Visual Studio for debugging, or need to debug a non IE problem that you are having writing scontrols, you should check out FireBug.
AJAX Toolkit for Smarties
by Dave Carroll on September 16, 2005 at 02:33 PM
AJAX Toolkit for Smarties
First I would like to thank everyone that came to the AJAX session at Dreamforce '05. The session was well attended and the question and answer period was very constructive.
There was one question in particular that I'd like to repeat. The question was "Will you be adding UI widgets to emulate the salesforce look and feel to the toolkit?". My answer was no. Instead, the philosophy behind the toolkit that salesforce.com will provide now and in the future is to provide a core that simplifies the ability to consume the salesforce.com web service. That will be the base toolkit. I would like to begin building libraries of widgets (an overworked term to be sure) and extensions that add value to the toolkit. I encourage everyone interested to do the same and to publish these using our community forum for the use of other developers as well. A great widget to start with would be to emulate the little magnifying glass link on our standard edit pages. This link brings up a search dialog in the context of the field that it is next to. I have already seen one of these in action and it may be available sooner than later.
I have had a lot of requests for some of the samples that I demonstrated during the session. At the bottom of this post you will find links to these samples.
I would like to comment on the "FullTest" sample to properly set expectations. This page was assembled as I was casting about trying to find a reasonable way to perform comprehensive testing on the toolkit. This means that the code was built organically without really having a grand scheme in mind, please be kind. The idea beahind this page was to create a "namespace" in which I could create discrete tests that could be run one at a time or as a group. To do this I identify each test process by prepending sf_ before each function that contains a discreet test process. This allows for an introspective-like capability to determine which functions are part of the test and to, once identified, run all or some of the tests. Also, for quick troubleshooting and behavior reproduction, I added a text area in which you can cobble together a function and eval it to inspect the results as well as the soap request/response messages. You should use https://www.salesforce.com/services/Soap/u/7.0 for the server url and https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js for the url to the script libraries.
Download FullTestBeta3.html Test Harness
This is a simple page that demonstrates many of the features.
Ecosystems versus centralized development
by PK on August 31, 2005 at 04:31 PM
Nice post that mentions the Sforce Ecosystem
http://blogs.zdnet.com/SAAS/?p=17
What are your thoughts about it?
Another Great Scontrol - Convert Opportunity Products to Assets
by PK on August 23, 2005 at 12:25 AM
Here's a killer sample using the new AJAX toolkit that takes opportunity products, and gives you a screen to convert them to assets.
Many thanks to Andrew for this one!
To deploy this sample:
1.
Create a custom field on Opportunity *Named* "Assets_Created_Date".
(This is the name as it would appear in Salesforce.com. If you label it
"Assets Created Date" the Name should default to the correct value).
This field, if available, will be set on completion and will prevent
assets from being created from the oppty again.
(If you don't want
to create this field you'll have to remove the merge field from the
code (it's in there twice), otherwise you will not be able to save the
S-Control form as it validates merge fields. The code does not require
this field to exist.)
2. Download the attached html file
3. Open it in a editor
4. Copy code and paste into the Custom S-Control form
5. Save form. (If you didn't create the field as indicated in 1, this will fail)
6. Create a Custom Link on Opportunity.
- Choose "Open in salesforce window without sidebar"
- Make the height 700 pixels if you think you will have < 20 Assets
7. Add the link to your Opportunity Page Layout.
-Optionally-
8.
Create a custom field on Product *Named* "Not_Unit_Based". (Same rules
as 1, above). This field, if available and checked, will change the
default behavior of one row in the form per unit of each line item
(Asset quantity = 1) to one line in the form per line item (Asset
quantity = Opportunity Line Item quantity).
PHP 5's SOAP Extension and Salesforce
by PK on August 17, 2005 at 11:54 AM
The guys at Zend have done some things to make PHP5 really easy to use with Sforce. Check it out:
http://www.suraski.net/blog/index.php?/archives/5-PHP-5s-SOAP-extension-and-SalesForce.html
AJAX Toolkit
by Dave Carroll on July 28, 2005 at 02:19 PM
Introducing the AppExchange” AJAX Toolkit Beta 3.3
As Google Maps and a number of other innovative new web apps have shown, when pushed to its limits JavaScript is capable of some pretty amazing things. The catch has been that it requires a heroic amount of JavaScript rocket science to make work, which can be painful to develop and debug. Sforce developers who have tried to develop client side s-controls with JavaScript have likely experienced this directly.
The new AJAX Toolkit opens the door to powerful, s-control based extensions to Salesforce that take advantage of AJAX. Not only can you build sophisticated apps that don’t require any server infrastructure possible, it also makes it easy. The toolkit exposes the complete Sforce API in JavaScript with the same methods and syntax you already know – making developing s-controls a breeze. Better yet, the toolkit works in all major browsers, including IE, Firefox and Safari, ensuring that your s-controls run cross platform without requiring additional work.
Want to “mash up” Sforce with another Web service like Google Maps? Need to create a new UI for a layout or custom object? Want to create a print view or roll up of other data? With the AJAX Toolkit, the possibilities are virtually endless. So download the attached zip to review the docs and samples, and make sure you sign up for the AJAX session at Dreamforce to get hands on training with the new toolkit. As the toolkit is still beta, make sure you let us know about what you’ve built, and bugs you find or suggestions for improvements.
Note: Like all of our open source projects, the AJAX toolkit is supported only through the Sforce message boards.
Two sample Custom S-Controls, a more detailed how-to and java doc describing the objects in the toolkit can be had here Download docs.zip .
Cross Platform Scontrol
by PK on June 1, 2005 at 08:18 PM
Here's a simple piece of code that works on Firefox and IE using XMLHttp to query the Sforce API. Works as an Scontrol to display data from an account.
Your Old Friend P3P
by PK on May 10, 2005 at 04:48 PM
This is an oldie but goodie, but and as I ran across this issue today, though I share it again - the perils of P3P and embedding your Web app inside the Salesforce UI.
http://sforce.com/resources/tn-11.jsp
At risk of spoiling the ending, the answer is
response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD
IVAi IVDi CONi HIS OUR IND CNT\"")




