Title: SControls for Dummies
1S-Controls for Dummies
Track Enterprise Edition Administrators
- Chris Sommers, Salesforce.com
- Senior Sales Engineer, Global Enterprise Accounts
2Safe Harbor Statement
- Safe harbor statement under the Private
Securities Litigation Reform Act of 1995 This
presentation may contain forward-looking
statements the achievement of which involves
risks, uncertainties and assumptions. If any such
risks or uncertainties materialize or if any of
the assumptions proves incorrect, our results
could differ materially from the results
expressed or implied by the forward-looking
statements we make. All statements other than
statements of historical fact could be deemed
forward-looking, including any projections of
subscriber growth, earnings, revenues, or other
financial items and any statements regarding
strategies or plans of management for future
operations, statements of belief, any statements
concerning new, planned, or upgraded services or
technology developments and customer contracts or
use of our services. - The risks and uncertainties referred to above
include - but are not limited to - risks
associated with the integration of Sendia
Corporations technology, operations,
infrastructure and personnel with ours
unexpected costs or delays incurred in
integrating Sendia with salesforce.com, which
could adversely affect our operating results and
rate of growth any unknown errors or limitations
in the Sendia technology any third party
intellectual property claims arising from the
Sendia technology customer and partner
acceptance and deployment of the AppExchange and
AppExchange Mobile platforms interruptions or
delays in our service or our Web hosting our new
business model breach of our security measures
possible fluctuations in our operating results
and rate of growth the emerging market in which
we operate our relatively limited operating
history our ability to hire, retain and motivate
our employees and manage our growth competition
our ability to continue to release and gain
customer acceptance of new and improved versions
of our CRM service unanticipated changes in our
effective tax rate fluctuations in the number of
shares outstanding the price of such shares
foreign currency exchange rates and interest
rates. - Further information on these and other factors
that could affect our financial results is
included in the reports on Forms 10-K, 10-Q and
8-K and in other filings we make with the
Securities and Exchange Commission from time to
time, including our Form 10-K for the fiscal year
ended January 31, 2006. These documents are
available on the SEC Filings section of the
Investor Information section of our website at
www.salesforce.com/investor. - Any unreleased services or features referenced in
this or other press releases or public statements
are not currently available and may not be
delivered on time or at all. Customers who
purchase our services should make purchase
decisions based upon features that are currently
available. Salesforce.com, inc. assumes no
obligation and does not intend to update these
forward-looking statements, except as required by
law.
3Agenda
- What are S-Controls?
- When to use S-Controls
- S-Controls Techniques Examples
- AJAX Introduction
- Examples and Resources
- Take Home Exercises
4What are Custom S-Controls?
- Light-weight web applications/tools hosted by
salesforce.com and executed on the client browser - An s-control can contain any type of content that
can be displayed or run in a browser - Java Applet
- ActiveX Control
- HTML / JavaScript / AJAX
- S-Controls are activated via Custom Links, Web
Tabs, Web Apps or HYPERLINK custom formulae
fields in salesforce.com (after 4th Quarter
release, executable in Detail Pages of records,
and Custom Buttons)
5S-Control Options
AJAX
JSP / ASP
Java Applet
ActiveX
- Rich UI
- Can be trusted
- Tricky deployment
- eg. Salesforce.com Mail Merge
- Rich UI
- Can be trusted
- Cross-browser
- Rich UI
- Good access to internal systems
- Familiar dev environment
- Pretty rich UI
- Simple API access
- Asynchronous
- Familiar html environment
- Javascript / cross-browser
- Quick and easy cycle
- Easy to package and share
- No back-office access
- State persistence
- Versioning issues
- IE Specific
- COM calling COM
- JVM versioning
- SOAP stack deployment
- Large footprint
- Java developer
- Need a hosting stack
- Expensive development
- Packaging and sharing is difficult
6When to Use Custom S-controls (Value!)
- Consider using Custom S-controls if you
- Want to enhance the Salesforce UI
- streamline a process
- reduce number of clicks
- Know that your process flow is closed loop, i.e.,
no outside databases or data sources - Have less than 500 records to create or update
per session - Have few means to host a custom web application
yourself
7When to Use Custom S-controls
- User Interface Enhancement
- Add your own UI
- Advanced Capabilities (trees, graphs etc)
- Build Custom Logic
- Client-side Workflow (wizard)
- Mass Change to records
8When NOT to Use Custom S-controls
- Do NOT use Custom S-controls if you
- Are looking to build heavy-weight,
computationally intensive extensions to
Salesforce - Are seeking a complex integrate with a system
external to Salesforce.com (simple web-service
and HTTP post/get will work!) - Have more than 500 records to create or update
per session
9Example Pre-populate / create records in One
Click
- What One-click creation of a record
- Why Efficiency, user adoption
- Value Simplicity, adoption, data quality
- Example One click to log a case (eg. Password
Reset) - Create a Custom Link on a Contact page to create
a Case and prepopulate the fields (and save) - How In the app, from a Contact, click on New
Case. Copy the URL this is your web link
BASE. - https//na1.salesforce.com/500/e?retURL2F0033000
000M1lutdef_contact_id0033000000M1lut
10Log Password Reset Case
Tip After Winter 07 Launch, use a Custom Button
Instead
11Example Pre-populate / create records
- Remove everything up to and including the .com
- Need to make it server agnostic
- /500/e?retURL2F!Contact_IDdef_contact_id
- !Contact_IDcas14Password20Resetcas11Phones
ave1 - retURL is the page to which user should return
after completing action - 003 is the Contact ID. Replace this with
merge field !Contact_ID - Replace the second Contact ID with the same
!Contact_ID - Continue building out parameters
- View the page source, or use Form View in Firefox
Web Developer to get the name of the fields you
wish to pre-populate - eg. Case Subject is cas14, Case Origin is
cas11
12Preventing Double-Tabbing
ltscript language"Javascript"gt function
redirect() parent.frames.location.replace('/500/
e?retURL2F!Contact_ID def_contact_id!Contac
t_IDcas14Password20Reset cas11Phonesave1')
redirect() lt/scriptgt
13Example Parameterize Reports
- What One-click dynamic generation of a report
- Why Efficiency, scalability
- Value Simplicity
- Example Generate a report dynamically passing
filters
Tip After Winter 07 Launch, use a Custom Button
Instead
14Example Parameterize Reports
- How
- Create a report, filter by desired field
- Copy the report URL
- Create a Custom Link on the entity
- In the custom link URL box, paste in the report
URL - At the end of this URL string add the following
text?pv0MERGE_FIELD - Eg. /00O30000001D5tZ?pv0!Account_Name
- Use pv0 if your criteria filter is in position 1
in your report, pv1 if it is in the 2nd position,
and so on
15AJAX
- What Asynchronous Javascript And XML
- Why Rapid Software, Component Development
- Value Adoption, low cost
- Example Mass Update Contact Addresses
- Before AJAX
- With AJAX
16The AJAX Toolkit Object Model
17SforceClient Method Summary
18AJAX - Key Components
- SforceClient
- https//www.salesforce.com/services/lib/ajax/beta3
.3/sforceclient.js - Dynamic SObject - DynaBean
- S-Control Context and Merge Fields
- Common Functions
- Query Call
- Retrieve
- Create Call
- Update Call
- Delete Call
- Save Call
19sForceClient
- Within the ltheadgt section
- ltscript src"https//www.salesforce.com/services/l
ib/ajax/beta3.3/sforceclient.js"
type"text/javascript"gtlt/scriptgt - Instantiated on script inclusion
- sforceClient.init("!API_Session_ID",
"!API_Partner_Server_URL_70") - Call sforceClient.init or sforceClient.Login
- sforceClient.init("!API_Session_ID",
"!API_Partner_Server_URL_70")
20Dynamic SObject - Dynabean
- Uses a single object - a Dynabean - to represent
every available table in the database - Dynabean is a dynamic object that contains both
data and metadata that determines its character - Example
- var myLead new Sforce.Dynabean(Lead")
- myLead.set(FirstName, Stan)
- myLead.set(LastName, Lee)
- myLead.set(Company, ABC Company)
- var saveResult sforceClient.Create(myLead)0
21Query Call
- Example
- var queryResult sforceClient.Query("Select
BillingCity, BillingCountry, from Account Where
Id '" accId "'") - var address queryResult.records0
- var BillingCity address.BillingCity
- var BillingCountry address.get(BillingCountry)
22Example Close Opportunity, Create Order and
Order Items
- What In one click from an Opportunity, need to
- Close Opportunity
- Create Contract
- Create Order with Contract Reference
- Copy Opportunity Products to Order Items
- Why Too many clicks without, poor
user-experience - Value Minimizes user error, improves data
quality and user satisfaction
23Example Search First, Create
- What Enforce that users search for existing data
before creating new records - Custom Web Tab (today)
- Override Standard New button after Winter 07
- Use search parameters to populate new records if
desired - Why Cleaner data NO DUPLICATES
- Value Minimizes duplicates/improves data quality
and user satisfaction
24Create Call
- var accounts new Array()
- accounts0 new Sforce.Dynabean ("Account")
- accounts0.set("Name", "test1")
- accounts1 new Sforce.Dynabean ("Account")
- accounts1.set("Name", "test2")
- var rc sforceClient.Create(accounts)
- if (dltypeof(rc) "array")
- // do something with the returned created ids
- else
- alert( rc.toString() )
-
25Update Call
- accs0 new Sforce.Dynabean ("Account")
- accs0.set("Id", !Account_ID")
- accs0.set("Name", "test Updated")
- var sr sforceClient.Update(accs)
-
- var qr sforceClient.Query("Select Id,
MailingCountry from Contact Where AccountId '"
accId "'") - var updateObjects new Array()
- for (var i0iltqr.records.lengthi)
- var contact qr.recordsi
- contact.set("MailingCountry, United Kingdom)
- // push updated record into new array for update
process - updateObjects.push(contact)
-
- var saveResults sforceClient.Update(updateObject
s)
26Delete Call
- var accounts new Array()
- accounts0 new DynaBean("Account")
- accounts0.set("Name", "test")
- var sr sforceClient.Create(accounts)0
- var dr sforceClient.Delete(sr0.id)
- if (dltypeof(dr) "array")
- for (var i0iltdr.lengthi)
- alert( dri.toString())
-
- else
- alert( dri.toString())
27Calling an S-Control using HYPERLINK field
- For HYPERLINK custom formulae fields or for
calling an scontrol from another scontrol - Create a Custom Link as usual
- Add to page layout
- View record and right click on link-properties
and copy the url section - /servlet/servlet.Integration?lid00b30000000hXeLe
id00130000005YmJ5 - lid s-control id and eid context entity
record - Replace the hard coded eid with the id of the
current record
28Tools and Techniques
- Development Environment
- Text editor (Wordpad, 1st Page 2000, Ultraedit)
- Eclipse (javascript specific plugins)
- Visual Studio .NET
- Other standard IDEs
- Debugging
- MS Script Debugger (ok)
- Visual Studio .NET (best)
- Mozilla/Venkman Debugger (ok)
- Mozilla Javascript Console
29Tools and Techniques
- Recommend installing Firefox and then adding the
following extensions - Web Developer 0.9.3
- JavaScript Debugger 0.9.84
- View Rendered Source 1.0.01
- Test with IE and Firefox.
- Handle cross browser exceptions
- Firefox doesnt allow cross site scripting
- Firefox is stricter on language semantics
- Firefox better for debugging
30Techniques - Debugging
- Debugging support in the toolkit
- setDebugContainer(element)
- sforceClient.setDebugContainer(document.getElement
ById(mydiv) - sforeceClient.setDebugContainer(document.getElemen
tById(myTextArea) - sforceClient.debugMessage(This is a point in the
script.) - setMessageLog(textArea)
- Displays the SOAP requests and responses
- setTimingDebugger(textArea)
- displays the elapsed time to execute a method.
- Javascript alert statement
- alert(Error message error)
- Debugger / output to the Javascript console
31Passing parameters to an S-Control
- Yes if the scontrol is called via HYPERLINK in a
custom formulae field, YES, this is possible - No if the scontrol is called via a Custom Link
or Web Tab - Yes within an scontrol additional parameters can
be added to the URI for a call to a second
scontrol - HYPERLINK("/servlet/servlet.Integration?lid01N300
0000009KEeid" !Id "addressbilling",
"Test Link") - eid parameter can be accessed in the s-control to
get the current entity context record if needed
32Other (Non AJAX) S-Controls Techniques
- Parameterise Reports
- Pre-populate / create records
- Preventing double tabbing on salesforce.com web
links - Manipulating return urls and page chaining
- Calling an S-Control
- Passing parameters to an S-Control
- Style Sheets Replicating salesforce.com look
and feel - Standalone AJAX application
- Calling s-controls on home page HTML components
33Style Sheets Replicating salesforce.com look
and feel
- Different style sheets per language and for
Salesforce Classic and the new interface - Need to pickup the right style sheet to maintain
look and feel within the scontrol - userUiSkin returns a value indicating the CSS
path that should be specified - Salesforce1 /dCSS/Theme1/en/common.css
- Salesforce2 /dCSS/Theme2/en/common.css
- common.css should be the only file you need to
use to replicate the salesforce.com's look and
feel. - For full details see tech note http//www.sforce.c
om/resources/tn-16.jsp
34Standalone AJAX application
- Use divs to present / hide a login screen
- Call sforceClient.Login(username_at_somedomain.com,
secret) instead of sforceClient.init(sessionid
, endpoint) to initialise sforceClient - If running as a standalone application use the
frontdoor urls when calling back into
salesforce.com to prevent the user being prompted
to login to salesforce.com through the web
interface - https//ltinstancegt.salesforce.com/secur/frontdoor.
jsp?sid!API_Session_IDretURL/ltURI to
required pagegt
35Calling s-controls on home page HTML components
- Can be used to display dynamic content on the
home page - S-controls and merge fields are not supported
directly within the HTML component so uses an
embedded iframe calling an scontrol web link - Create an scontrol
- Create a home page custom link and temporarily
add it to a home page layout (to capture the URI) - Create an HTML component My Salesforce.com (name
not important)
36Calling s-controls on home page HTML components
- Check the Show HTML check box
- Add the following text to the HTML component
- ltIFRAME src"/servlet/servlet.Integration?lid00b2
0000000i5QOampeid00520000000hTCf"
frameBorder0 width"100" height"100"gtlt/IFRAMEgt
- (Replace the lid and eid parameter values with
those captured in the step above) - Note as no record has context from the home page
you cannot use merge fields in the scontrol
(other than !API_Enterprise_Server_URL_60 and
!API_Session_ID)
37Additional Examples
- AJAX Account create New Opp and Task.htm
- - this is a pure s-control that is designed to
work from a web link on an account. It creates
an opportunity, amends the opp return url and
opens the opp in edit mode. - AJAX update address of all contacts on an
account.htm - - this one is another pure s-control again driven
from the account which updates all the addresses
of linked contacts to the account to have the
account address. This one shows a small popup
window 'Updating Contact Addresses' as it does
the processing and then self closes in this case
as nothing has changed on the account it doesn't
bother to refresh the underlying record. - AJAX List of all cases and associated
solutions.htm - - this one can be used either as an s-control or
as a standalone browser app. It loops through
all the cases and sees what solutions are
associated with it and displays the results with
clickable links to the cases and solutions
referenced. It is specific to na1 and when used
standalone needs another login when the urls are
clicked (urls do not use the 'frontdoor'
notation).
38Resources
- AJAX Toolkit
- http//blog.sforce.com/sforce/2006/04/ajax_toolkit
_be.html - Can host locally
- Can include in document repository
- /servlet/servlet.FileDownload?fileDocument_ID
- www.salesforce.com/developer
- Tech Notes
- Community forums search on AJAX