| Type | Title | Author |
|---|---|---|
| Forum topic | WebEx Connect Integration Availability | kreester |
| Notebook entry | Day One Dream Factory | chuckbrady |
| Notebook entry | how to animate a sprite | butcher |
DreamFactory is both an IDE and a runtime engine for rich internet applications.
Let's look at some of the basic facts about DreamFactory
Salesforce.com has a robust and well-supported service architecture - the AppExchange API. The following pages will walk you through everything you need to know to build a DreamFactory application that leverages the Salesforce API.
DreamFactory consists of a software engine and various project files. The engine is either an ActiveX control, a Netscape Plug-in or a stand-alone executable.
The stand-alone version of the DreamFactory and the browser plug-ins are available from:
http://www.dreamfactory.org/download/
Download and run the DreamFactory Professional installation program. The stand-alone IDE will be installed, along with a desktop shortcut and a Start > Programs > DreamFactory menu item.
After installation, the DreamFactory installation folder will contain help files, default scripts, plug-ins, a download folder, and some other text files. The DreamFactory document type uses the extension .dfac and the registered MIME type application/dreamfactory.
Browser based authors will not see the menu bar pictured at the top of the screen below. Instead, the system menus are available as a pop-up from the Message Box, Debugger, or Script Editing Windows in the Menu button to the right of the information bar. Other than that, the standalone and browser-based IDE are identical.
The Utility Palette contains all the key buttons that contol what Palettes you see on your screen. The Utility Palette at right provides access to many useful functions with a tool bar. Expand the window by clicking in the zoom box to see more controls.
Let's look at the available controls on the Utility Palette:
| Icon | Function |
![]() |
Click this button to open an existing DreamFactory project. |
![]() |
Click this button to close an existing DreamFactory project. |
![]() |
Click this button to save your existing DreamFactory project. |
![]() |
Click this button to zip up a copy of your DreamFactory project and deploy it on the Internet. |
![]() |
Click this button to close all projects and quit DreamFactory. |
![]() |
Click this button to run the current project. Click this button twice to resume editing of the project. |
![]() |
Click this button to launch the degugger on your current project. |
![]() |
Click this button to open the Message Box and run new scripts. |
![]() |
Click this button to show/hide the Tools Palette. |
![]() |
Click this button to show/hide the Project Manager Palette. |
![]() |
Click this button to show/hide the Alignment Palette. |
![]() |
Click this button to check for updates to the libraries, palletes, and dialogs in DreamFactory. |
The Tools Palette launches every time you open a project.

Click the main Tools icon at the top of the Tools Palette (upper left) to cycle through the various node types available in DreamFactory. You can choose from
|
• Draw • Window • List • Tabl • Menu • Gauge |
• Button • Border • Rich Text • Slider • Chart • Misc |
Note: Click the Maximize button to expand the Tools Palette to show all available node types.
Figure 1 above shows the Draw nodes that are available in DreamFactory. Let's look at how to get started on a project and some of the key functions you can use on the Tools Palette.
The Alignment Palette allows you to align or nudge currently selected objects. Use the Tools Palette Reshaper Tool to select nodes to align. Ctrl-click to select multiple nodes.
Right-click on any DreamFactory node on your main screen and you will see a pop-up menu with a list of available options, with a Properties option at the bottom of the menu. The first menu items will always be:
| Menu Item | Function |
| Help | Click this button to open the help system for that node |
| Name | Click this button to give the node a name |
| Script | Click this button to view or edit the node script |
| Resize | Click this button to activate the handles on the node and to drag or resize the node. Press Ctrl + click to select or deselet multiple nodes. Use the Alignment Palette to move nodes around. |
| Target | Click this button to direct the Message Box to call commands and functions on the selected nodes. |
| Comment | Click this button to create a comment for this particular node. |
The next set of available menu options are: Cut, Copy, Paste, Delete, and Duplicate. These are self explanatory, but be aware that these operations apply to the node and all of its children.
At the bottom of most pop-up menus you should see the Properties Dialog, for example, "Slider Properties." You can also access this by double-clicking most nodes.
The Properties Dialog lets you explore the various capabilities of a node. Figure 3 below shows the property dialog for aSlider.

There are some important DreamFactory system windows that are used to help author and build your projects:

The Debugger is accessible at any time. The Debugger can set breakpoints and step through scripts as they execute. The Debugger also tracks the values of local, global, and regional variables. It will display the hierarchical overview of your project in Outline Form. When the Debugger is active, all script execution stops, but you can still edit scripts and use the Message Box. Simply click the Run button to continue execution, or Step to watch the current script run. Scan your mouse over the various buttons on the Debugger Window and they will document themselves.
The Message Box allows instant execution and exploration of the DreamFactory language.
Right-click any node and select the Target pop-up menu command. The Message Box will then send typed messages to that node, so you can call handlers from the hierarchy, reference variables, etc.
The Message Box is a good place to create or change node properties manually or test the scripting language. Press Ctrl + scan with the mouse to identify visible nodes by name.
The Help System documents all system and plug-in commands. The system commands arranged in logical groups with common prefixes. The Help Window is always available and is context sensitive. It is intended as a general DreamFactory reference.
The Background Desktop is the main window that stores the project and all its nodes. This window is where all project editing takes place. Be aware that objects in the Background Desktop are all part of your project, even if they look like windows, menus, or other system windows. The Debugger, Message Box, and Script Editing Windows float on top of the Background Desktop.
The Script Editing windows provide powerful editing features and allow you to work on multiple DreamFactory scripts at once. When you are editing a script, press Ctrl + scan with the mouse to see any language element documented and explained in the information bar at the top of the window.
Click Ctrl + F to open up the Find Dialog (Command-F on the Mac) to search and replace the current script, the current hierarchy, or all scripts in the current project.
Click to the left of the script in the dotted rectangle to set or clear break points; when the script runs this point it will trigger the Debugger Window.
The Menu button to the right of the information bar in the Message Box provides access to DreamFactory system menus.
All DreamFactory functionality is provided by what we call plug-ins. Some plug-ins are standardand are available at all times.
The standard plug-ins are:
|
• Chart • Button • Draw • Icon • Menu • Picture • Sprite • Table • Window |
• Border • Desktop • Gauge • List • Movie • Sound • Slider • Text • XML |
Plug-ins can also be non-graphic, such as the Outlook plug-in that provides desktop integration with Microsoft Outlook. New plug-ins can be developed when needed. They become first-class entities that expose their own commands and functions. Plug-ins are version controlled and downloaded as necessary to support DreamFactory projects.
Each node has an associated plug-in and script. Most of the commands and functions exposed by a plug-in control the visual appearance of a node. Often a script will use these commands or functions to manage the appearance and behavior of a node. While the details of each node can be controlled by the associated plug-in commands and functions, there are also system commands and functions used for controlling the characteristics of all nodes in general. For example, the system command nodevisibleset("mynode", false) will hide any node regardless of the associated plug-in.
In this tutorial you will create the simplest DreamFactory application. It will consist of a dialog with a button. When you press the button, a "Hello World! popup dialog will appear.

You can see that all the button has been relabelled OK.
The final part of this tutorial will show you how to add code to a button. Let's continue with our example.
mycontent function to look like:
code mycontent(hor, ver)
dialogshow("Hello Title", "Hello World!")
endcode

Note: There is no need to save the overall project in the IDE because it is continuously saved. There is also a limited undo. i.e., be careful about your changes. Changes are not easy to undo.
In the case of a button, mycontent() will be called when the button is pressed. Each node has a mycontent() function - initially empty - that is called when that node is activated. Here are some examples of actions that will trigger a node's mycontent() handler:
| Handler | Action |
| List | A list item was seleted |
| Text | A mouse was clicked/released in the text field |
| Table | A cell was selected |
| Menu | A menu item was selected |
Sometimes, things go wrong. In this tutorial, you'll learn about the debugger built into the DreamFactory IDE and how it can help you with errors.

Wait - before you dismiss the dialog, note the following choices you have:
Now, before we forget, fix your scripting error by reinserting the comma and saving the script.
This tutorial will cover all you need to know about window/dialog manipulation. Instead of using a system function to pop up a dialog box, we're going to create our own window and pop it up and down ourselves. We're also going to add list and text nodes to our original window. Then we will make our window and all of its children resize smoothly.
There are a lot of steps to this tutorial, so we have broken it down into smaller stages.
The first part of this tutorial involves creating a second dialog window. For information on how to create a dialog window, see Tutorial 1 - Hello World.

Now let's make our new dialog pop up and down.
code mycontent(hor, ver)
nodevisibleset("mypopup, true)
nodebringtofront("mypopup)
endcode
This will make your new "My Popup dialog appear, and it will bring it to the fore ensuring that it isn't obscured by any other windows.
code mycontent(hor, ver)
nodevisibleset("mypopup, false)
endcode
This, in turn, will hide your My Popup dialog.

When you click the Dismiss button in your My Popup dialog window, the pop-up window will close.

If you look closely at the node hierarchy in the Project Manager palette, you'll see that both window:mypopup and button:dismiss are blue in the node hierarchy.

This indicates that these nodes are not visible. Right-click on window:mypopup and select Show Node. This will make your popup dialog visible once again.
Now we're going to add three children to My Popup:

If you look in the Project Manager palette, you'll see that you actually created two nodes: a border and a list. The border provides the scrolling, and the list will actually contain whatever items you populate it with.
Note: You can do this either through its Properties dialog or by right-clicking on the node and selecting Enter Text.
You're My Popup dialog should now look like this:
One of the other handlers (functions) that is very useful is nodemove(). When a node is moved or resized, nodemove() is called (makes sense, doesn't it?) The most common use of nodemove() is for a parent (a dialog or window) to reposition its children based on its size.
For this part of the tutorial, we're going to do something simple. We're going to keep the Dismiss button at the bottom right of the My Popup window no matter how we resize the window.
First, let's make My Popup resizeable.
If you resize now, you'll see that all of the children of My Popup, including the Dismiss button, stay exactly where they are, regardless of the size of the window.
What we want, though, is for the Dismiss button to remain anchored to the bottom right corner of the window.
code nodemove()
local mybounds, mybutton, button_bounds, width, height
// Find my child button
mybutton = nodefindchild(me, "dismiss")
// Get the bounds of the window and the button
mybounds = window.boundsget(me)
button_bounds = button.boundsget(mybutton)
width = button_bounds.width
height = button_bounds.height
// Anchor the button 20 pixels up and to the left
// of the lower right corner of the window
button_bounds.right = mybounds.width - 20
button_bounds.bottom = mybounds.height - 20
button_bounds.left = button_bounds.right - width
button_bounds.top = button_bounds.bottom - height
// Set the button's bounds accordingly
button.boundsset(mybutton, button_bounds)
endcode
The salesforce.com application suite is an on-demand offering, accessed through a traditional browser-based interface. Salesforce.com also has an online marketplace - the AppExchange - where both salesforce.com and their partners offer applications and add-on components that run on top of the salesforce.com platform.
Salesforce.com was one of the first application vendors to create a truly robust web services interface. DreamFactory has been providing development tools and building applications for salesforce.com using this API - now branded as the Apex Web Services API - since its inception. Through the API, you can programmatically do almost (but not quite) everything you can do through Salesforce's own browser-based UI.
For developers, it is useful to know that the salesforce.com platform is built on an Oracle database. Salesforce entities like Account, Opportunity and Lead are implemented as tables in that database, and relationships between entities are fundamentally foreign keys into those tables. The Apex API reflects that underlying structure. The uniformity of the underlying data model simplifies the effort of building applications that interact with salesforce.com entities. The basic set of operations is exactly what you would expect: Login, Describe, Retrieve, Search, Filter, Create, Read, Update, Delete, etc. Refreshing, isn't it?
Salesforce.com has a wealth of background information on AppExchange, the Apex Web Services API and much more. You can access all of that information at the Apex Developer Network site. This tutorial will walk you through the basic "getting started steps, but we also recommend you take a look at the salesforce.com site. Here are pointers to some of the more relevant items:
In the DreamFactory IDE and runtime, we've greatly simplified the process of building applications that integrate with salesforce.com. Read on!
In the Project Manager palette, under desktop:mydesk you'll see window:access_panel. This node will be blue in the palette, because the node is currently hidden.




In the Project Manager palette it is a child of desktop:mydesk and in the UI you will see the integration panel.
In this part of the tutorial, we're going to import the Salesforce Integration Panel into our tutorial application. This will let us begin integrating with Salesforce, and it'll teach us a bit about DreamFactory library and node copying.
To access the Salesforce Integration Panel, we're going to open a second DreamFactory project (application). This project is called StartingPoint, and the easiest way to get it is this:
This will open Starting Point in your browser, and it will also download the actual project file to this folder:
C:\Program Files\DreamFactory\downloads\www.dreamfactory.com\startingpoint\
startingpoint.dfac
This will switch you into development mode, where you can see all the palettes you're now accustomed to.

You now have two projects open at the same time in the DreamFactory IDE. You can easily switch between projects via the File > View Project menu.
From StartingPoint we want to grab three things: the Salesforce Integration Panel UI and two convenience libraries.
In the Project Manager palette, under desktop:mydesk you'll see window:access_panel. This node will be blue in the palette, because the node is currently hidden.




In the Project Manager palette it is a child of desktop:mydesk and in the UI you will see the integration panel.
In DreamFactory, libraries are convenient places to keep scripts that are used throughout your project. The first six libraries - library1 through library6 - are created by default when you begin a project. From there, you can add libraries as you see fit.
To copy a library, basically you have to create a new library and then copy the contents from another library into it. Follow these steps to copy the Salesforce Integration libraries from startingpoint.dfac to tutorial.dfac. We'll also be creating our own library for this tutorial.
The Message Box allows instant execution and exploration of the DreamFactory language.





Most of these functions will be used directly by the Salesforce Integration Panel, but you'll use some of them yourself in this tutorial.
library8, Tutorial Library is empty for now. It will eventually have a function that is used by library9, though, so it is important that it appears before the Sforce Persistence library.

In this part of the tutorial, we're going to start making actual calls to salesforce.com. Since we don't want to mess with real production data, we're going to use a Developer Account. It's easy to get one, and we'll walk you through the process right now.
Salesforce.com is eager to get you (and every other developer on the planet) building applications on their platform. If you join the Apex Developer Network (ADN), they'll give you a free two-user Developer Edition Account. This account has all of the application functionality of the Enterprise Edition, and it comes pre-loaded with sample data including Accounts, Contacts, Leads, Opportunities, etc.
To set up a free salesforce.com account, follow these steps:
Note: Remember your username (it's the email address you provided in the form) and password. We'll need them later in this tutorial.
sforce_login("dfdeveloper@dreamfactory.com", "tutorial")
Note: We still want to popup My Popup, so don't remove that code. Your script should look like this when you're done:
code mycontent(hor, ver)
sforce_login("dfdeveloper@dreamfactory.com", "tutorial")
nodevisibleset("mypopup", true)
nodebringtofront("mypopup")
endcode
Don't forget to save your script. You won't notice anything new when you press the OK button, other than a slight delay while the login to salesforce.com is happening, but you've just made your first Web Services call from your DreamFactory application to salesforce.com!
Lead is a standard Salesforce object and one of the most common integration scenarios is extracting Lead data from salesforce.com and passing Lead data into salesforce.com. Let's make a call to salesforce.com to gather some lead data. We will populate the List box in My Popup with the Lead data we retrieve.
However, we still need to declare the leads variable and populate the list with our Lead data.
code mycontent(hor, ver)
local leads
sforce_login("dfdeveloper@dreamfactory.com", "tutorial")
leads = sforce_filter("Lead", "Id, Name, Title", "Name != 'Z'")
list.dataset("list_contents", leads)
nodevisibleset("mypopup", true)
nodebringtofront("mypopup")
endcode
If you want to see the full set of XML data returned, use the Salesforce Integration Panel (Sforce Console).
We know that 22 leads were returned and we can scroll through and see all of the lead data. The Salesforce Integration Panel is a really useful debugging/testing tool.
That didn't solve our problem, though. How can we slog through the XML data? Do we actually have to parse it? The short answer is "No but read on to lean more.
In this tutorial, we'll learn how to work with salesforce.com data. We will use some of the functions in the Sforce persistence library we copied into our project. We will also modify our popup window to allow us to send updated data back to salesforce.com.
The primary purpose of the functions in the Sforce Persistence library is to make it easy to get data from salesforce.com, modify it locally and then update salesforce.com based on your local changes. As an example, by the time we're finished with this part of the tutorial, our popup dialog will:
The DreamFactory convention for a persistence layer is a hidden XML Palette that stores an unmodified version of the data (the original data) and a version of all locally-made changes. Elements in the palette are created, updated and deleted locally. When you're finished making changes, you simply pass your XML palette to the xml_update_palette() function in the Sforce Persistence library. xml_update_palette() will identify all of your changes, additions, deletions and modifications and then make the appropriate calls to salesforce.com to apply your changes.

This is the palette that will be used by the Sforce persistence library to see what you've changed.

One of the conventions across all DreamFactory applications is the special_object function. This application-specific convenience function takes a node's name and returns the fully-qualified pathname of that node in the node hierarchy. The Sforce Persistence library depends on this function, so let's add it to our Tutorial Library. Here is the code for this function:
code special_object(what)
local thename, prefix
switch what
case "master_scratchpad"
thename = "<window:master_scratchpad"
case "master_leads"
thename = "<window:master_leads"
default
report_error("bad window", "unknown special window: " @ what)
return empty
endswitch
prefix = nodefindplugin(nodefirst(), "desktop")
return prefix @ thename
endcode
code mycontent(hor, ver)
local leads
sforce_login("dfdeveloper@dreamfactory.com", "tutorial")
leads = sforce_filter("Lead", "Id, Name, Title", "Name != 'Z'")
xml_store_data("master_leads", leads)
nodevisibleset("mypopup", true)
nodebringtofront("mypopup")
endcode
To populate our list, we need to pull the Lead data out of the palette. We will only display the Lead names in the list. We'll take advantage of a property of the List node to match list items with the corresponding items in the XML palette.
code populate_list(mylist, xml_palette)
local count, itemId, nameId, name
list.dataset(mylist, empty)
for count = 1 to xml.countelements(xml_palette, 0)
itemId = xml.indextoelement(xml_palette, 0, count)
nameId = xml.findelementchild(xml_palette, itemId, "Name")
name = xml.elementvalueget(xml_palette, nameId)
list.insertitem(mylist, count - 1)
list.itemnameset(mylist, count, name)
list.itemrefset(mylist, count, itemId)
endfor
list.reset(mylist)
endcode
Let's look at some of the important points about this code:
Now we need to call this new function from our OK button's mycontent() script.
Note: The XML palette (master_leads) actually consists of a parent window with a child XML node. It is actually the child XML node that we want.

Now that we're pulling and displaying Leads from salesforce.com, let's take it one step further. Let's display the Title of the selected Lead. First, let's change the label above the text box node in My Popup.


Let's also change the name of our Text Box node so that it's easier to use.
lead_title in the Project Manager Palette.
Now, let's display the Title for each Lead selected in the list.
Note: Ensure you have the list's script and not that of its parent border.
code mycontent(newitem)
local xml_palette, itemId, titleId, title
itemId = list.itemrefget(me, newitem)
xml_palette = nodechildget("master_leads")
titleId = xml.findelementchild(xml_palette, itemId, "Title")
title = xml.elementvalueget(xml_palette, titleid)
text.dataset("lead_title", title)
text.textrefset("lead_title", titleId)
endcode
This code is doing two things:

It would be nice to be able to change the Titles of our Leads, wouldn't it? Let's do that now!
First we need to add a button to do the local update.


code mycontent(hor, ver)
local xml_palette, item, itemId, titleId, title
item = list.selectget("list_contents")
itemId = list.itemrefget("list_contents", item)
title = text.dataget("lead_title")
xml_palette = nodechildget("master_leads")
titleId = xml.findelementchild(xml_palette, itemId, "Title")
xml.elementvalueset(xml_palette, titleId, title)
endcode
Let's look at what this code is doing. When you click on the Change Title button, it is
The last thing we want to do is actually update salesforce.com. Remember, we're using a Developer account so we won't be changing production data.

The My Popup window should look like this.

Now let's make the Save button function.
We're now going to use the xml_update_palette() function in the Sforce Persistence library. All we have to do is pass it our XML palette, and it does the rest.
code mycontent(hor, ver)
xml_update_palette("Lead", "master_leads")
nodevisibleset("mypopup", false)
endcode
Now change the title for one of the Leads.
Note: This is only making the change locally.
If you log into your salesforce.com Developer account and look at this Lead, you can see the change you just made:

At this point, we've gone end-to-end. We've built a simple DreamFactory application that integrates with salesforce.com through the Web Services API. Pretty cool!
So far, we've had fun playing in the DreamFactory IDE, but to actually publish DreamFactory applications and to launch them in a browser or from within salesforce.com, you'll need to package your application. DreamFactory makes this really easy.
A DreamFactory application is just a single binary file - in this tutorial, it's called tutorial.dfac. It's a registered MIME type, and it's easy to launch in any browser or anywhere there is an IFrame to house it.
Packaging a DreamFactory application is a two-step process from within the DreamFactory IDE:
Move on to Tutorial 7 to see how to do this.
Note: If you want to protect your application, you can also lock and password-protect the zipped project file.
It's time to package our application. In this part, we'll assume that you're running a local web server (something like IIS) for testing. We'll package the application, generate an HTML stub, put both into a folder on our web server and launch our application from a browser.
Before you zip your application, you need to hide all of the development -time windows:

You can't zip a project you're actively editing, so close tutorial.dfac.

Note: The tutorial.dfac file should end up being less than 500KB in size.
In the future, you'll be able to click Skip. That'll still zip your project file, but it won't regenerate an HTML stub. Unless you need to change its location or properties, here's no need to regenerate the HTML stub.
When you click the OK button for the first time you'll see a security popup dialog.

You don't yet have a developer certificate, so the DreamFactory runtime wants to make sure you trust your application to connect to another server (salesforce.com in this case).
Congratulations... We just logged into salesforce.com, queried to get a list of Leads and displayed them in our popup! Now grab your My Popup dialog and move it around - it's just like a desktop app, but it's running in your browser!

You just created a completely server-less (100% client-side) application that can talk to any Web Services server anywhere. It can even talk to more than one back-end system at the same time - try to do that that in AJAX!
Here is the stub created by DreamFactory. Note two key things:
<HTML>
<HEAD>
<title>DreamFactory 6.40 Project: tutorial.dfac</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY bgcolor="#FFFFFF" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<object
classid="clsid:226906C8-B911-11D5-82A3-0000F81A655B"
codebase="http://www.dreamfactory.com/codebase/dfacactx.cab#Version=6,4e,0,1"
id="dfacinst"
border=0
width=100%
height=100%>
<param
name="htmldata"
value="Pass any string to your project here...">
<param
name="openfile"
value="http://localhost/tutorial/tutorial.dfac">
<embed
type="application/dreamfactory"
pluginspage="http://www.dreamfactory.com/codebase/winplug.exe"
width=100%
height=100%
htmldata="Pass any string to your project here..."
openfile="http://localhost/tutorial/tutorial.dfac">
</embed>
</object>
</BODY>
</HTML>
There are several ways to integrate a DreamFactory application into the salesforce.com user interface. The most common ways include
All three of these integration mechanisms has advantages and disadvantages. Custom links have been around longer than the others, so you will see custom links more often than the others. Custom buttons are becoming more popular, as they are more intuitive and better looking - a button stands out more, so is easier for users to find and use. Inline S-Controls are very interesting, because they allow you to pop up something - your DreamFactory application, for instance - without having to take over the entire page. DreamFactory's commercial applications make use of all three of these integration mechanisms:

In this picture, Carousel (our dynamic presentation, report and dashboard application) is presenting an opportunity dashboard directly in an Opportunity page, using an inline S-Control. OrgView (graphical organization charts) launches from a custom link.
In the next tutorial, we'll integrate your DreamFactory application into salesforce.com via a custom button. Once you know how to use one of the integration mechanisms, you have all of the information you need. They are all very similar in the way they work and in how you configure them. Salesforce.com has a built-in help system and examples available if you need additional information.
In this tutorial, we'll create a custom button in our salesforce.com developer account. We'll configure the button to launch your DreamFactory application, and you'll nearly be done!
Creating a custom button in salesforce.com is a two-step process. First, you create the button and configure its behavior. Then you need to include the button in a page layout. In salesforce.com, a page layout defines which fields, buttons, etc. will be displayed on a page, and in what order. The salesforce.com UI is a traditional two-column HTML layout, so you don't have a lot of flexibility in your UI. That's one of the advantages of DreamFactory - you can make your application look, behave, and interact in any way you like.
Log into your salesforce.com developer account. The login URL is: https://www.salesforce.com/login.jsp
At the top of the page, click "Setup. On the left side of the page, under "App Setup, click "Customize, then "Leads and then "Buttons and Links. This will take you to a page that lets you create a custom button on the "Leads tab.

Click "New to create a new custom button.
In the next page, fill in the Label and Description. The "Behavior" dropdown lets you decide whether your application will pop up in the current page or in a new browser window. Let's choose "Display in existing window with sidebar. This will launch our DreamFactory application in the current page. Choose "Detail Page Button for the Display Type and "URL as the Content Source. In the large text field at the bottom, enter the URL for the HTML stub you created in Part 7 of this tutorial. For me, the URL is http://localhost/tutorial/tutorial.html

When you click "Save" you'll see the following popup:

You still need to add your button to the Leads page layout in order to see and use it. On the left side of the page, under "Leads", click "Page Layouts" and then click the "Edit" link next to "Lead Layout":

To add your button to the page layout, click on "Detail Page Buttons" in the Button Section and then click the "Edit Properties" button just above the Button Section:

In the popup, select your new button in the "Available Buttons" list on the left, click the right arrow (Add) so that your button appears in the "Selected Buttons" list on the right, and click "OK":

Click through this popup

and then click "Save" at the top (or bottom) of the "Edit Page Layout" page.
There. You've created a custom button in salesforce.com, and you've configured it to launch your DreamFactory application. Now let's try it out! Click on the Leads tab

and click on any of the Leads listed. On the detail page for that lead, you'll see your new custom button:

Click on the button - go ahead, it won't bite! Et voila! Your DreamFactory application will appear inside salesforce.com!

We're almost done! We've gone from zero - no DreamFactory IDE, no salesforce.com account, nothing - to a DreamFactory application that is integrated with salesforce.com and launches from within the native Salesforce UI. The final step is to package your application so that you can share it with others.
In this part of the tutorial we will create an AppExchange application with its own custom tab. That tab will house your DreamFactory application. We'll then create what Salesforce calls an AppExchange Package. You can make that package available to others via the AppExchange.
First, let's create a custom tab. Log into your salesforce.com devekoper account, if you're not already there. At the top of the page, click "Setup". On the left side of the page, under "App Setup", click "Build", then "Custom Tabs" and then click the "New" button next to "Web Tabs".

This will start a 5-step "wizard" to create your custom Web Tab. In Step 1, click "2 columns with Salesforce sidebar" and then click "Next".

In step 2, select "URL" as the Tab Type. Give your tab a label, style and description and click "Next".

In step 3, enter the URL of your HTML stub. This will be the same URL you used for your custom button in the previous part of the tutorial. In my case, the URL is http://localhost/tutorial/tutorial.html

In step 4, just click "Next". In step 5, uncheck all of the boxes on the right and click "Save". We'll add our new web tab to the custom app we're about to make in a few minutes.

Now let's create a custom application. On the left side of the page, under "App Setup", click "Build", then "Custom Apps" and then click the "Continue" button on the right.

On the Custom Apps page, click "New".

This will start a 4-step "wizard" that will help you create your custom app. In Step 1, give your application a label and description.

In step 2, just click "Next". In step 3, select your custom tab - "My Leads" in the "Available Tabs" list on the left. Click the right arrow (Add) to move your tab into the "Selected Tabs" list on the right and click "Next".

In step 4, make your new app visible to all user profiles by clicking the checkbox next to the "Visible" label at the top. Click "Save" to complete your new custom app.

To test your new app, go to the Appexchange dropdown in the upper right corner of the salesforce.com pane. There should be an entry for your new app. Select your app froim the list. You'll see two tabs now: "Home" and "My Leads". Every salesforce.com app has a "Home" tab - that's not the interesting part. Click on "My Leads" and you'll see your DreamFactory application running in your new custom tab.

Finally - the last step! To share your application with other salesforce.com users, you need to create an AppExchange package. This package will allow someone else to install your application in their salesforce.com org (account). If you want to sell your application on the AppExchange, you need to go through Salesforce's certification process. I don't think our app is quite ready to sell yet, so let's just create a private package.
At the top of the page, click "Setup". On the left side of the page, under "Exchange", click "Shared Apps" and then click the "New" button next to "Package List".

Give your package a name and description, and click "Save".

Click the "Add" button next to "Package Items".

Click the checkbox to the left of your new custom app ("My Leads") and click "Add To Package".

Now, under "Package Items" you will see both your custom app and your custom web tab. Your custom app includes your web tab, so Salesforce was nice enough to include both for you. Click "Upload to AppExchange" to upload your new package.

Give your package a version and click "Upload to AppExchange" one more time.

This time, the upload will really happen. When the upload is complete, click the "here" link to check on your package status.

Click the "Register" button to register your package with AppExchange.

The "Reference URL" in the next page is the link yo your new AppExchange package. Click on this link to see your new package, or give it to a friend to install in another salesforce.com org.

Click on the link, and you'll be there - your package on the AppExchange! This is a private package, so you can't search for it on the AppExchange. You'll have to give the URL to anyone with whom you want to share your package.
