You are on page 1of 65

Table of Contents

Table of Contents ............................................................................................................ 1


Exercise 2-1: Creating a Custom Application .................................................................. 2
Exercise 2-2: Creating a Custom Object ......................................................................... 4
Exercise 2-3: Creating a Custom Tab ............................................................................. 6
Exercise 2-4: Adding Fields to a Custom Object ............................................................. 8
Exercise 2-5: Customizing a Page Layout..................................................................... 10
Exercise 3-1: Setting Organization Wide Defaults......................................................... 14
Exercise 3-2: Implementing Sharing Rules ................................................................... 16
Exercise 3-3: Implementing Manual Sharing................................................................. 18
Exercise 4-1: Using the Force.com Data Loader........................................................... 20
Exercise 5-1: Writing a Simple Console Application...................................................... 21
Exercise 6-1: Creating an Inline S-Control .................................................................... 27
Exercise 6-2: Overriding a Standard Button .................................................................. 29
Exercise 6-3: Creating Detail Button Activated S-Controls............................................ 31
Exercise 6-4: Creating a Custom Link ........................................................................... 33
Exercise 6-5: Creating a Mass Action List Button and JavaScript ................................. 35
Exercise 7-1: Completing the API SalaryConsole Application....................................... 37
Exercise 7-2: Monitoring an API Application ................................................................. 39
Exercise 7-3: Converting the Salary App into a Standalone Web Control ..................... 41
Exercise 7-4: Converting Salary App into an Integrated Web Control ........................... 43
Exercise 8-1: Integrating a Corporate Website with the Recruiting App ........................ 45
Exercise 9-1: Creating a Personal Share on the AppExchange Directory..................... 47
Exercise 10-1: Installing the Force.com Toolkit Eclipse Plugin ..................................... 49
Exercise 10-2: Creating a Force.com Project in Eclipse................................................ 51
Exercise 11-1: Creating a Hello World Apex Class and Trigger .................................... 53
Exercise 12-1: Creating a Standalone Delete Prevention Trigger ................................. 55
Exercise 13-1: Creating an Automated Sharing Model.................................................. 57
Exercise 14-1: Creating a Test Class ............................................................................ 59
Exercise 15-1: Deploying Apex into Another Salesforce Org ........................................ 60
Exercise 16-1: Creating a Candidate Duplication Check............................................... 62
Exercise 16-2: Creating a Custom Web Service for the Candidate Duplication Check . 64

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-1-
Exercise 2-1: Creating a Custom Application
Goal(s):
• Create a custom Recruiting application.

Scenario:
• The first step in creating any Force.com App is to create the container to hold all
of the associated objects, tabs, etc. The simplest app contains only the default
Home tab, and a default logo.
• We will now create a custom Recruiting app for Universal Containers and
associate their logo with it. As we build more functionality into our app, we will
add it to this application container.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Apps
2. If you see the splash page, click Continue
3. Click New
4. Step 1: Enter the Details
a. Label: Recruiting
b. Description: enter a brief description
c. Click Next
5. Step 2: Choose the Image Source for the Custom App Logo
Click Insert an image
a. File Location: Corporate Graphics
b. Click the link for the Universal containers.gif file
c. Click Next
6. Step 3: Choose the Tabs
a. Select Reports, Documents, Dashboards, Interviewers, Candidates,
Positions, and Job Applications from the Available Tabs and move them
to the Selected Tabs box
b. Click Next

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-2-
7. Step 4: Assign to Profiles
a. Make the app visible to all profiles by checking the Visible checkbox in the
column header
b. Make default for Hiring Managers
c. Click Save

Review
1. How do you switch applications as a user in the Salesforce user interface?

________________________________________________________________
________________________________________________________________

2. Can a Salesforce object exist independent of an application?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-3-
Exercise 2-2: Creating a Custom Object
Goal(s):
• Create a Review custom object.

Scenario:
• Universal Containers (UC) is currently using a spreadsheet to track interview
reviews. This is a very inefficient process that is difficult to manage.
• In order to improve this process and make it more efficient, UC has decided to
create a custom object to track reviews. All internal communication and activity
relating to a review should be tracked on this object. In addition, users should be
able to run reports on this object.

Time:
• 5 minutes

Instructions
8. Click Setup | Create | Custom Objects
9. Click New Custom Object
10. Enter the Custom Object Information
a. Label: Review
b. Plural Label: Reviews
c. Object Name: Review (should be auto-populated)
d. Description: enter a brief description
11. Enter Record Name Label and Format
a. Record name: Review Name
b. Data Type: Auto Number
c. Display format: REV-{0000}
d. Starting Number: 1
12. Select Optional Features
a. Check Allow Reports
b. Check Allow Activities
c. Check Track Field History

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-4-
13. Deployment Status: Select Deployed
14. Click Save

Review
3. What database object is similar in concept to a custom object? What further
advantages does a Salesforce object provide?

________________________________________________________________
________________________________________________________________

4. Where in the application is the plural label used?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-5-
Exercise 2-3: Creating a Custom Tab
Goal(s):
• Create a custom tab for the Candidate object.

Scenario:
• Universal Containers wants to make sure that users will be able to easily access
the new Candidate object. They need to create a new custom tab that will
quickly guide people to this information.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Tabs
2. In the Custom Object Tabs section, click New
3. Enter the Details
a. Object: Review
b. Tab Style: Thermometer
c. Splash Page Custom Link: leave blank
d. Description: enter a brief description
e. Click Next
4. Add to Profiles
a. Select Apply one tab visibility to all profiles: Default On
b. Click Next
5. Add to Custom Apps
a. Uncheck all applications except the Recruiting application
b. Check the box to Append tab to users’ existing personal customizations
6. Click Save

Review
1. If you do not create a custom tab for your object, is the data still accessible?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-6-
________________________________________________________________
________________________________________________________________

2. When selecting the Default Off option on the tab profile information, how can
users make the tab visible?

________________________________________________________________
________________________________________________________________

3. Why might you choose to not create tabs for some Salesforce objects?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-7-
Exercise 2-4: Adding Fields to a Custom Object
Goal(s):
• Add custom fields to the Review custom object.

Scenario:
• Universal Containers has identified several fields that need to be available on the
Candidate custom object.

Custom Field Custom Field Type Picklist Values / Notes

Alternate Position Text Area(255) Help Text: Other positions that this
candidate might be better suited for.
Cultural Comments Text Area (255)
Cultural Fit Number (1,0)
Experience Number (1,0)
Experience Comments Text Area (255)
Job Application Master-Detail (Job Related List Label: Reviews
Application)
Leadership Comments Text Area (255)
Leadership Skills Number (1,0)
Recommend for Hire Checkbox Default: Unchecked
Overall Score Formula (Number) Decimal Places = 2, Create the following
formula using the Advanced Formula tab:
( Cultural_Fit__c +
Experience__c +
Leadership_Skills__c + IF(
Recommend_for_Hire__c , 5,
1) ) / 4

Time:
• 10 minutes

Instructions
1. Click Setup | Create | Custom Objects | Review
2. In the Custom Fields & Relationships related list, click New
3. Follow the steps to create the custom fields listed in the table above

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-8-
a. Accept the defaults to set all fields as visible to all profiles and to added to the
Review Page Layout
b. Click Save & New to create the next field in the list

Review
1. What is the difference between a Master-Detail and a Lookup relationship?

________________________________________________________________
________________________________________________________________

2. Does marking a field as required here ensure that it is always required?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
-9-
Exercise 2-5: Customizing a Page Layout
Goal(s):
• Create a basic page layout for the Review object.

Scenario:
• Universal Containers wants to make sure that the newly created fields are
displayed in a logical order on the page. The fields should be arranged according
to the chart below.

Section Name Fields

Review Name Created By

Recommend for Hire Last Modified By


Information
Job Application

Overall Score

Cultural Fit

Cultural Comments

Experience

Scores Experience Comments

Leadership Skills

Leadership Comments

Alternate Position

Time:
• 5 minutes

Instructions

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 10 -
1. Click Setup | Create | Custom Objects | Review
2. In the Page Layouts related list, click the Edit link to the left of the Review
Layout
3. Create the sections specified in the table above by clicking Create New Section
4. Arrange the fields within the sections as noted in the table above by dragging
them from the Review Fields area in the lower right, or from within other
sections of the page layout
5. Click Save

Review
1. What purpose do the sections serve in a page layout?

________________________________________________________________
________________________________________________________________

2. Does marking a field as required here ensure that it is always required?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 11 -
Exercise 2-6: Creating a Validation Rule

Goal(s):
• Add a validation rule to ensure that the duration value must be entered for temp
positions.

Scenario:
• Universal Containers hires part-time, full-time employees and temporary
positions. To account for this, a Type field is on the Position object. Often, when
a new temporary position is created the record creator forgets to specify the
duration of the engagement.
• By using validation rules we can conditionally require that in order to save a
position record the duration must be specified that is a number greater than zero
if the Type field value is equal to Temp.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Objects | Position
2. In the Validation Rules related list, click New
3. Enter the Validation Rule Details
a. Name: Temp_Duration_Validation
b. Active: True
c. Description: We must require that the duration is specified
if the position type = Temp
d. Error Condition Formula: AND( ISPICKVAL( Type__c , "Temp"),
NULLVALUE(Duration__c, 0) <=0 )
e. Error Message: Duration required when Type = “Temp”
f. Error Location: Field | (Duration)
4. Click Check Syntax to verify your formula
5. Click Save
6. Click on the Position tab and create a new position to test this validation rule

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 12 -
Review
1. Are validation rules executed for fields that are stored in the object but not part of
the displayed page layout?

________________________________________________________________
________________________________________________________________

2. Are validation rules executed when loading data through the API or the Data
Loader? Are there exceptions?

________________________________________________________________
________________________________________________________________

3. If a new rule is created and there is data already stored that violates that rule,
when will Salesforce catch the problem?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 13 -
Exercise 3-1: Setting Organization Wide Defaults
Goal(s):
• Use organization wide defaults (OWD) to restrict edit permissions for position
data.

Scenario:
• At Universal Containers, standard users (who are not recruiters), hiring
managers, or interviewers, are only allowed to view position data. There will
never be any position that a standard user is not permitted to see.
Standard users are not ever allowed to edit any position records.
• What must the OWD for position data be in Universal Containers’ Recruiting
application? Implement this OWD for Universal Containers.

Time:
• 5 minutes

Instructions
1. Click Setup | Security Controls | Sharing Settings
2. If you see a splash page, click Set Up Sharing
3. Click Edit to edit the Organization Wide Defaults
4. Set access on the Position object to Public Read Only
5. Click Save

Review
1. What are the two questions that you should ask yourself when trying to decide
how to set OWD permissions for an object?

________________________________________________________________
________________________________________________________________

2. What is fundamentally different about the way OWDs affect data than all of the
other data access controls?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 14 -
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 15 -
Exercise 3-2: Implementing Sharing Rules
Goal(s):
• Add a sharing rule to provide access to records for the VP Human Resources
role users and their subordinates.

Scenario:
• Establish sharing rules at Universal Containers to accomplish the following:
• Grant recruiters read and update access to every position, candidate, job
application, and review record in the application.

Time:
• 5 minutes

Instructions
1. Click Setup | Security Controls | Sharing Settings
2. If you see the splash page, click Set Up Sharing
3. In the Position: Sharing Rules related list, click New
a. Positions: owned by members of: Public Groups | Entire
Organization
b. Share with: Roles and Subordinates | VP Human Resources
c. Access Level: Read/Write
d. Click Save
e. Click OK to the dialog box that appears warning that This operation
could take significant time
4. Repeat for the Candidate and Job Application objects

Review
1. Are the users who are part of the VP Human Resources role able to share
positions that they are granted access to through this rule?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 16 -
2. What are the types of components you can share records with through sharing
rules?

________________________________________________________________
________________________________________________________________

3. Try repeating the process to share records for the Review object. What is the
reason for what you find?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 17 -
Exercise 3-3: Implementing Manual Sharing
Goal(s):
• Add manual sharing for various profiles to grant access on records where they
are invested in the information.

Scenario:
• Establish manual sharing at Universal Containers to accomplish the remaining
access levels: Grant hiring managers read access on candidates where they are
the hiring manager. Grant interviewers read access on job application and
candidate records for people they are interviewing.

Time:
• 5 minutes

Instructions
1. Select a position record you want to share (Note: This must be accomplished on
a record by record basis by the owner, manager of owner, or system
administrator of a record)
a. Click the Positions tab
b. Select a position (you may need to click Go next to the view to populate a list
of positions), and take note of the Hiring Manager
c. Click Sharing
2. User or Group Sharing
a. Click Add
b. Search: Users
c. Add the Hiring Manager user on the position to the New Sharing box with
Access Level: Read/Write
d. Click Save
3. Note: This would have to be repeated for each specific object record to be
shared as required

Review

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 18 -
1. Why is this method not appropriate for a system-wide solution?
________________________________________________________________
________________________________________________________________

2. Who are the three types of users that can grant sharing privileges on a given
record?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 19 -
Exercise 4-1: Using the Force.com Data Loader
Goal(s):
• Load the position, candidate, and job application CSV data using the Force.com
Data Loader.

Scenario:
• AW Computing used to keep position, candidate, and job application information
in a series of Excel spreadsheets. As part of the switch over to the new
Salesforce Recruiting application, the old Excel data was consolidated into CSV
files that need to be uploaded into Salesforce.

Time:
• 10 minutes

Instructions
1. Install the Data Loader if it is not previously installed by double-clicking the
installer located at C:\AppExchangeLabExercises\ApexDataLoader.exe
and keep all of the installation defaults
2. In Windows Explorer, navigate to the C:\dataload\bin directory
3. Double-click fileGrep.exe to replace the tokens in the command line scripts
with your own username
4. When prompted, enter your class org username and click Run (You should
receive a message stating that 2 files were updated)
5. Double-click the dataload.bat file located at C:\dataload\bin to start the
data load using the command line scripts
6. Upon completion of the data load, examine the contents of the
C:\dataload\conf folder to view the load setup and the C:\dataload\data
folder to see the CSV data
7. Log into the application and verify that the loaded data can be seen there (Do not
forget to change the objects views to All to see all records)

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 20 -
Exercise 5-1: Writing a Simple Console Application
Goal(s):
• Generate the WSDL and consume it in the appropriate environment.
• Complete the SOQL statement left unfinished to query Salesforce through the
API in the OpenPositions console program.

Scenario:
• The IT staff at Universal Containers (UC) wants to learn how the Web Services
API works. Help UC modify existing sample query code and SOQL syntax to
display open Position data from their org.
• Choose your preferred development language: Java, VB.Net, or C#.Net. Note
that the instructions for Java and the .Net languages will vary slightly.

Time:
• 15 minutes

Instructions
1. Generate the WSDL
a. Click Setup | Develop | API
b. Click the Download Enterprise WSDL link
c. Save to the WSDL to the root C:\ directory as
Enterprise_version.wsdl

For Java:
2. Double-click the Eclipse application shortcut located on your desktop (If
prompted for a workspace, select the default and check the box to always use
the default workspace before continuing on)
3. Create a new project
a. From the menu, select File | New | Project…
b. Select Java project and click Next
c. Project name: OpenPositions
d. Click Next
e. Click on the Libraries tab

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 21 -
f. Click Add External JARs
g. Navigate to C:\axis-1_3\lib, select all of the jar files listed and click
Open
h. Click Finish
4. Import and consume the WSDL
a. Right-click the OpenPositions project and select Import…
b. Select General | File System and click Next
c. Browse to the WSDL location at C:\, select the
Enterprise_version.wsdl file and click Finish
d. In the left navigation pane, expand the project, right-click
Enterprise_version.wsdl and select WSDL2JAVA | Generate… (This
process will take a minute and should result in three
com.sforce.soap.enterprise* packages at the top of your project)
5. Import the client code
a. In the left navigation pane, right-click the OpenPositions project and select
New | Package
b. Name: com.salesforce.openpositions
c. Click Finish
d. Right-click this new package and select Import…
e. Select General | File System and click Next
f. Browse to the
C:\AppExchangeLabExercises\programming_language\OpenPosit
ions directory, select OpenPositions.java, and click Finish
g. In the navigation pane, double-click OpenPositions.java to open the
client code

For .Net:
2. Select Start | Microsoft Visual Studio 2005 | Microsoft Visual Studio 2005
3. Create a new project
a. Select File | New | Project…

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 22 -
b. Select either a Visual C# or a Visual Basic Console Application template,
depending on your preferred code language
c. Name: OpenPositions
d. Click OK
e. Delete the automatically generated default file (Module1.vb or
Program.cs)
4. Import and consume the WSDL
a. In the right navigation pane, right-click the Open Positions project and select
Add Web Reference…
b. URL: C:\Enterprise_version.wsdl
c. Click Go
d. Web reference name: sforce
e. Click Add reference
5. Import the client code
a. In the right navigation pane, right-click the Open Positions project and select
Add | Existing Item…
b. Browse to C:\AppExchangeLabExercises\programming_language
\OpenPositions\OpenPositions.cs (or OpenPositions.vb) and click
Add
c. Right-click the OpenPositions project and select Properties
d. Select the Startup object: OpenPositions.cs (or OpenPositions.vb)
instead of the default and close the properties window

For Both:
6. In the OpenPositions code, locate the getPositions() method /
Positions() subroutine and write a SOQL query for the variable
queryString that retrieves the Name, Type, and Status fields for all positions
where Status=Open to replace input SOQL query string here!
7. Test the code via the following methods

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 23 -
• Java: Right-click OpenPositions.java and select Run as | Java
Application which will both compile and run the code
• .Net: Right-click the OpenPositions project and select Debug | Start new
instance (or enter F5) which will both compile and run the code

Review
1. Is the Salesforce WSDL programming language independent? If so, why are
there separate code files for each language?

________________________________________________________________
________________________________________________________________

2. Why did we not just use Select * from Position__c for our query?

________________________________________________________________
________________________________________________________________

3. Would this code work for a large number of open positions? What would we
need to change to make it scalable?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 24 -
Exercise 5-2: Examining a Schema with the Force.com
Explorer

Goal(s):
• Install the Force.com Explorer and use it examine the schema.
• Practice creating SOQL queries using the Force.com Explorer.

Scenario:
• Universal Container’s IT staff wants to examine their org’s metadata. Help them
download and install the Force.com Explorer. Examine Universal Container’s
metadata with the describeGlobal and describeSObject API calls used by
the Force.com Explorer. Create SOQL statements from the user interface and
run them against your Salesforce org.

Time:
• 10 minutes

Instructions
1. Download the Force.com Explorer from the Apex Developer Network (ADN) or
locate in the local directory
C:\AppExchangeLabExercises\ApexExplorer.zip
2. (Note: you will need to log into the ADN with your Developer Edition credentials
to access the Force.com Explorer page)
3. Browse to www.salesforce.com/developer
4. Select Tools under the Apex Wiki sidebar
5. Locate the Development Tools section and click the Apex Explorer link to
access the page
6. Click Apex Explorer to download the Explorer
7. Unzip the downloaded file
8. Run the installer, accepting all defaults
9. Run the Explorer by double-clicking on the Apex Explorer icon on the desktop
10. Enter your username and password for the org you wish to inspect
1. Examine your orgs schema using the SOQL Tester tab and answer the following
questions below
salesforce.com proprietary/confidential: customer internal use only
©2000-2007
- 25 -
Review
1. Write a SOQL query to bring back the IDs of all positions and their related job
applications. How is the relationship of the parent object (Positions) and its child
object (Job Applications) reflected in the query structure?

________________________________________________________________
________________________________________________________________

2. Write a SOQL query to bring back the IDs of all positions and their related hiring
manager’s first and last names. How is the relationship of the child object
(Positions) and its parent object (Hiring Manager = User) reflected in the query
structure?

________________________________________________________________
________________________________________________________________

3. Looking at the answers above, how do you know when to use the two different
structures when creating SOQL queries?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 26 -
Exercise 6-1: Creating an Inline S-Control
Goal(s):
• Create the inline section to be used by an s-control to provide more information
on the job application page.

Scenario:
• To reduce the number of clicks recruiters must make to view Candidate
information for a Job Application, Universal Containers (UC) has decided to
create an inline s-control on the Job Application page layout that includes
Candidate information. The s-control will render a custom HTML page that
reveals the basic contact information of the Candidate associated to the Job
Application.
• The user experience is important to UC, and therefore the custom HTML page
should look and feel seamless to the user as if both the objects were part of the
same page.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Objects | Job Application
2. In the Page Layouts related list, click the Edit link next to the Job Application
Layout
3. Click Create New Section
a. Name: Candidate Information
b. Columns: 1 (Single)
c. Click OK
4. Double-click in the new Candidate Information section
a. Width=100%

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 27 -
b. Height =85
c. Click OK
5. From the View picklist on the right side, select Custom S-Controls
6. Drag the Related Candidate s-control into the new Candidate Information
section
7. Click Save
2. Click on the Job Application tab and test the new addition to the layout

Review
1. Notice that the inline section has the look and feel of the rest of the Salesforce
user interface. How is this accomplished?

________________________________________________________________
________________________________________________________________

2. Try editing a job application. Does this inline section appear on the edit page as
well? Why or why not?

________________________________________________________________
________________________________________________________________

3. Could this inline section be added into a related list section? Why or why not?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 28 -
Exercise 6-2: Overriding a Standard Button
Goal(s):
• Override the New button on the Review object to display a custom form.

Scenario:
• Universal Containers (UC) wants to create a custom HTML form to replace the
standard UI associated with the creation of a Review object. UC wants to kick off
this custom HTML form when the interviewer clicks the New Review button.
When the interviewer submits the custom HTML form, the field data should be
saved into a new Review record associated to the Job Application.
• Help UC override the New button of the Review object to display the custom
HTML form.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Objects | Review
2. In the Standard Buttons & Links related list, click the Override link for the New
button
3. Select the Custom S-Control: New Review
4. Click Save
5. Click the Review tab to test the customization by clicking New and notice the
warning message
6. Click the Job Application tab to test the customization by clicking on one of the
job applications and then clicking New on the Reviews related list
7. Fill out the form and click Save

Review
1. Does this override New only on that related list, or is it globally overridden for
reviews?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 29 -
________________________________________________________________
________________________________________________________________

2. Examine the code to find the JOB_LIST_LINK and notice that it is hard-coded to
be the URL prefix for the destination page. What would be a better solution?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 30 -
Exercise 6-3: Creating Detail Button Activated S-Controls
Goal(s):
• Finish an HTML s-control that will update Stage to Closed – Position
Closed for all open Job Application records associated to a specific position.

Scenario:
• Universal Containers receives numerous job applications per position. Once a
position has been closed it requires a great deal of effort (clicks) to close out
each job application associated to the position. Users would like a button to
perform a mass update on a position’s job application records that are in an
Open status to close them.
• Update the records’ Status to Closed and set the Stage to Closed –
Position Closed. Job Application records that are in a Hold or Closed
status should not be updated by the button.

Time:
• 60 minutes

Instructions
1. Click Setup | Create | Custom Objects | Position
2. In the Custom Buttons & Links related list, click New
a. Label: Close Applications
b. Name: Close_Applications
c. Display Type: Detail Page Button
d. Behavior: Display in new window
e. Content Source: Custom S-Control
f. Custom S-Control: Close_Applications - version
i. Click Save
ii. Click the Window Open Properties
iii. Width = 300
iv. Height = 200
v. Click Save
3. Click the Back to Custom Objects: Position link

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 31 -
4. In the Page Layouts related list, click the Edit link next to the Position Page
Layout
a. Near the top, double-click the Detail Page Buttons section
b. Add the custom button Close Applications to the Selected Buttons
c. Click OK
5. Click Save on the Position Page Layout page
6. Click Setup | Develop | Custom S-Controls
a. Click the Close Applications - version S-Control
b. Complete the JavaScript code in the Close Applications S-Control
Easy: Write a SOQL query to brink back the ID, Stage, and Status fields
from Job Application where the Status is Open and the Position ID is
equal to the Position ID supplied at runtime
Medium: Same as Easy, plus write Javascript code to loop through
returned records and update the fields Status to Closed and Stage to
Closed – Position Closed
Hard: Write the entire Javascript for the getApps() and updateApps()
methods, including what is required for Medium
c. Click Quick Save to save your work often
7. To test your work, click the Position tab and select a position
At the top of the page, click the Close Applications button

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 32 -
Exercise 6-4: Creating a Custom Link
Goal(s):
• Add a custom link to map candidates’ locations using an integration with Google
Maps.

Scenario:
• Due to the critical nature of the position, some positions require that the
employee live within a 30 mile radius of the site. In the past, recruiters had to
manually evaluate this distance for new candidates for these positions.
• One of the requirements for the application is to provide a simple way to see
where a candidate is located. Create a custom link to pop-up a mash-up of
Salesforce and Google Maps data.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Custom Objects | Candidate
2. In the Custom Buttons and Links related list, click New
a. Label: Map Candidate
b. Display Type: Detail Page Link
c. Behavior: Display in new window
d. Content Source: URL
e. URL: http://maps.google.com/maps?f=q&hl=en&q={!
Candidate__c.Street_Address_1__c }+{!
Candidate__c.City__c }+{! Candidate__c.State_Province__c
}&om=1
f. Click Save and notice the message regarding adding this link to a page layout
3. Click Window Open Properties
a. Width (in pixels): 600
b. Height (in pixels): 600
c. Click Save
4. Click the Back to Custom Object: Candidate link

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 33 -
5. In the Page Layouts related list, click the Edit link next to Candidate Layout
6. Change the View picklist to Candidate Custom Links
7. Drag the Map Candidate link to the Custom Links section at the bottom of the
layout
8. Click Save
9. Test the custom link by clicking the Candidates tab and clicking the Map
Candidate link on a Candidate record

Note: Although it is not vital to understand for this lab, you may be interested in the
parameters submitted in the request to the Google Maps API:
a. f=q means that this request takes the form of a query
b. hl=en means that the host language is English
c. q=… gives the address for the query
d. om=1 provides a true value for the opening of the overview map

Review
1. What are the requirements for integrating using this method?

________________________________________________________________
________________________________________________________________

2. In this example, what acts as the hook? What is the target?

________________________________________________________________
________________________________________________________________

3. Can this feature be used to pop up a new window that displays a different page
within Salesforce?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 34 -
Exercise 6-5: Creating a Mass Action List Button and
JavaScript
Goal(s):
• Finish a custom list button that rejects any user-selected job application records
regardless of what status the related position or job application record itself is in.
This will use only onClick JavaScript.

Scenario:
• Users are now so accustomed to closing out job application records using a
single button they now want a button that performs a mass action to reject job
application records they have selected regardless of the state of the position.

Time:
• 40 minutes

Instructions
1. Click Setup | Create | Custom Objects | Position
2. In the Page Layout related list, click Edit next to the Position Page Layout
a. Double-click the Job Applications related list
b. In the Custom Buttons section, add the custom list button Reject
Applications - version to the Selected Buttons
c. Click OK
3. Click Save on the Position Page Layout page
4. Click Setup | Create | Custom Objects | Job Application
a. In the Custom Buttons & Links related list, click Edit next to the Reject
Applications custom list button
b. Write the complete JavaScript code in the button editor
• Easy: Put the returned records into an array
• Medium: Same as Easy, plus use the records for a retrieve call to get
further fields and write a function to update the fields
• Hard: Write the entire code, including what is required for Medium
c. Use Quick Save to save your work often

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 35 -
5. To test your work, click the Position tab and select a position with multiple job
applications (you may need to create more job applications if they do not exist
already)
a. In the Job Applications related list, select at least one job application record
and click Reject Applications - version

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 36 -
Exercise 7-1: Completing the API SalaryConsole Application
Goal(s):
• Complete the API salary console application.

Scenario:
• Universal Containers (UC) wants to restrict min/max salary information on
positions to only those employees with a compelling need to know. UC has an
internal database that is used to store approved salary ranges for the various
positions and levels across departments.
• An application needs to be built to allow appropriate Salesforce users to view
salary information stored in the salary database for a position.

Time:
• 60 minutes

Instructions
1. Choose your development language: Java, VB.NET, or C#.NET
2. Prepare your environment for working with the SalaryConsole project
a. Java:
i. In the Eclipse IDE, close any open projects by right-clicking the project
and selecting Close
ii. Select File | Import | Existing Projects into Workspace…
iii. Browse to C:\AppExchangeLabExercises\Java\SalaryConsole
iv. Click Finish
v. Double-click the client code located in the project under
com.sforce.Salary.java
vi. Note that when you test, the console will appear in the output pane at the
bottom of the Eclipse IDE
b. .NET
i. In Windows Explorer, double-click the following file:
C:\AppExchangeLabExercises\.Net
language\SalaryConsole\SalaryConsole.sln

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 37 -
ii. Double-click the client code called SalaryConsole.vb or
SalaryConsole.cs
iii. Note that when you test, the console will appear as the usual console
window
3. Finish the code blocks outlined in the SalaryConsole application located at
C:\AppExchangeLabExercises\langauge\SalaryConsole… (Note that
the WSDL has already been consumed into the projects, so you will not need to
do that again)
a. Write the code to setup the binding URL and SessionHeader using the
LoginResult object (Note: consult the API documentation regarding the
login call)
b. Write code to query the Position object for the ID entered by the user which
returns PayGrade, HiringManager, ID, and OwnerID
c. Use the API Developer’s Guide as well as the Answers to help you if you get
stuck

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 38 -
Exercise 7-2: Monitoring an API Application
Goal(s):
• Intercept SOAP messages to and from the API to help with troubleshooting an
integration.

Scenario:
• Universal Containers is having trouble with their API console application after the
latest upgrade by Salesforce. Salesforce Support has been contacted and has
requested the SOAP requests and responses.
• Capture the SOAP messages generated from the login and query operations
of the API Console Application.

Time:
• 5 minutes

Instructions
1. Open the SalaryViewer project in either Eclipse or Visual Studio
2. Modify the endpoint of the binding to point at TCPMon (or TCPTrace):
http://locahost:8081/services/Soap/c/9.0
3. Open TCPMon (or TCPTrace) with the following parameters set (if you need to
change these, make sure that it is stopped first):
a. Listen on Port: 8081
b. Forward Destination Server: server-api.salesforce.com (You will
need to determine the appropriate server to insert above, such as: na1, eu0)
c. Destination Port: 80
4. Run the console application from the previous lab
5. Toggle over to TCPMon or TCPTrace to view captured SOAP messages

Review
1. If you know what the XML looks like, can you just send the XML directly into the
API? Is it possible to do this via an HTTP monitoring tool such as TCPMon?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 39 -
________________________________________________________________
________________________________________________________________

2. What problems might you encounter regarding TCPMon and passwords? How
could you get around this?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 40 -
Exercise 7-3: Converting the Salary App into a Standalone
Web Control
Goal(s):
• Convert the SalaryConsole application into a Standalone Web Control.

Scenario:
• The SalaryConsole application successfully allowed proper users to view and
edit salary information for a position, but deploying a console application to users
is extremely cumbersome. UC has decided to turn the Console application into a
Standalone Web Control so they don’t need to install it separately for each
user.
• Deploying it as a web control also allows them to present a cleaner UI to users
and better control the type of actions a user can make.

Time:
• 40 minutes

Instructions
1. Choose your development language: Java, VB.NET, or C#.NET
2. Prepare your environment for working with the SalaryStandAloneControl
project
a. Java:
iv. Copy the entire
C:\AppExchangeLabExercises\Java\SalaryStandAloneContro
l directory and paste it into C:\apache-tomcat-5.5.20\webapps
folder
v. In Eclipse, select File | Import | Existing Projects into workspace
vi. Browse to the same Tomcat folder you just pasted at C:\apache-
tomcat-5.5.20\webapps\SalaryStandAloneControl
vii. Locate the Main.java file under WEB-INF/src/… and complete the
code in the validateUser() method
viii. Complete the code in the Login.java file as well

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 41 -
ix. To test, you will need to start Tomcat using the shortcuts provided on the
desktop and use a browser to point to the URL:
http://localhost:8080/SalaryStandAloneControl/login.js
p
b. .Net:
i. Copy the entire C:\AppExchangeLabExercises\.NET
language\SalaryStandAloneControl folder and paste it into
C:\inetpub\wwwroot
ii. In the folder you just pasted, right-click the SalaryWorkbook.xsl file
and select Properties
iii. On the Security tab, select Launch IIS Process Account and click all of
the checkboxes in the Allow column
iv. Click Apply/Ok
v. On the desktop, right-click My Computer and select Manage
vi. Expand Services and Applications | Internet Information Services | Web
Sites | Default Web Sites
vii. Right-click SalaryStandAloneControl and select Properties
viii. Click Create next to the grayed-out Application Name
ix. Back in Internet Explorer, double-click the
C:\inetpub\wwwroot\SalaryStandAloneControl.sln file to
launch Visual Studio
x. Complete the code under AppCode/main.vb in the validateUser()
method
xi. Complete the code to pull in the username and password in
login.aspx / login.aspx.vb
xii. To test, use a browser to point to the URL:
http://localhost/SalaryStandAloneControl/login.jsp

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 42 -
Exercise 7-4: Converting Salary App into an Integrated Web
Control
Goal(s):
• Convert a standalone web control into an integrated web control available inline
on a Position Detail page.

Scenario:
• The SalaryStandAloneControl application successfully solved deployment
problems that Universal Containers was having. However, users began to
request that the SalaryControl be integrated seamlessly into the Salesforce
application so they wouldn’t have to toggle between the two applications.
• UC has decided to re-architect the application as an integrated web control so
that users will not have to provide login credentials nor enter the Position Id of
the Position record.

Time:
• 60 minutes

Instructions
1. Build the s-control
a. Click Setup | Develop | Custom S-Controls
b. Click New Custom S-Control
i. Label: SalaryControl
ii. Name: SalaryControl
iii. Type: URL
iv. .NET Content URL:
http://localhost/SalaryIntegratedControl/validate.aspx?sessionId=
{!API.Session_ID}&serverURL={!API.Enterprise_Server_URL_90}&
posId={!Position__c.Id}&userId={!$User.Id}
v. Java Content URL:
http://localhost:8080/SalaryIntegratedControl/validate.jsp?sessionId=
{!API.Session_ID}&serverURL={!API.Enterprise_Server_URL_90}&
posId={!Position__c.Id}&userId={!$User.Id}

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 43 -
vi. Click Save
2. Add the new s-control to the Position Detail Page Layout inline
a. Click Setup | Create | Custom Objects | Position
b. In the Page Layouts related list, click Edit next to the Position Page Layout
link
c. Click Create New Section
i. Name: Salary Information
ii. Columns: 1-Single
iii. Click OK
d. In the View picklist on the right-hand side, select Custom S-Controls
e. Drag the new SalaryControl s-control into the Salary Information section of
the layout
f. Double-click the SalaryControl s-control to access the display properties
i. Width: 100%
ii. Height: 200
iii. Scrollbars: Checked
iv. Click OK
g. Click Save
3. Choose your development language: Java, VB.NET, or C#.NET
4. Prepare your environment similarly to the last lab by copying over the application
into the web server folder
5. Finish the code blocks outlined in the SalaryIntegratedControl application
6. In the Main code file, implement the setupBinding rather than a login method
a. In the Validate code file, get the parameters as required
7. Test the application by clicking on the Position tab in Salesforce and examining a
Position

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 44 -
Exercise 8-1: Integrating a Corporate Website with the
Recruiting App
Goal(s):
• Build a recruiting website that uses Salesforce as its datasource and integrates
candidate job applications.
• Build the site using reusable components that leverage best practices.

Scenario:
• Universal Containers (UC) wants to publish the content for open positions
tracked in the Recruiting app on its corporate web site. UC IT wants to build a
solution that will allow the content creators (recruiters and hiring managers) to
manage publishing their own content easily and efficiently.
• UC would like candidates to apply for open positions through their web site and
have the data immediately fed into the Recruiting application.

Time:
• 60 minutes

Instructions
1. Choose your development language: Java, VB.NET, or C#.NET
2. Prepare your environment similarly to the last lab by copying over the application
into the web server folder
3. Change the username and password used in the configuration file located at
the following locations
a. Java: recruitingWeb\config.properties (Note: Do this using
Windows Explorer and a text editor outside of Eclipse)
b. .Net: recruitingWeb\web.config
4. Complete the code blocks in the Client file to implement the executeSOQL()
method using query and queryMore calls
a. Java: To test, you will need to start Tomcat using the shortcuts provided on
the desktop and use a browser to point to the URL:
http://localhost:8080/recruitingWeb/index.jsp

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 45 -
b. .Net: To test use a browser to point to the URL:
http://localhost/recruitingWeb/index.aspx

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 46 -
Exercise 9-1: Creating a Personal Share on the AppExchange
Directory
Goal(s):
• Upload the org used throughout this week to provide a way of migrating the
customizations you have made into another environment.

Scenario:
• Universal Containers has developed a fully functioning Recruiting application in
their Sandbox Environment. All testing has been performed and the IT staff is
ready to deploy the new app to their production environment.
• Package up the Recruiting application, upload it to the AppExchange Directory,
and register it to obtain the private URL.

Time:
• 5 minutes

Instructions
1. Click Setup | Create | Packages
2. Click New
3. Create an AppExchange Package
a. Package Name: Recruiting App
b. Description: enter a brief description
c. Click Save
4. In the Package Items related list, click Add
a. Select the Recruiting custom application
b. Click Add To Package
5. Under the Package Detail section, click Upload
a. Version Number: 1.0
b. Description: enter a brief description
c. Security: No password
d. There are no requirements for this package, so click Continue
e. Click Upload to AppExchange

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 47 -
f. Your package will then be uploaded. Click Refresh in the browser until the
Installation Link is provided
6. Share your private URL to allow others to access your app

Review
1. Is it possible to uninstall an application as well? What would this remove?

________________________________________________________________
________________________________________________________________

2. What happens if some of the objects that you are trying to install already exist in
the org?

________________________________________________________________
________________________________________________________________

3. What is a managed package?

________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 48 -
Exercise 10-1: Installing the Force.com Toolkit Eclipse Plugin
Goal(s):
• Install the Eclipse plugin that allows for Apex development.

Scenario:
• Universal Containers (UC) wants to start using Apex. To prepare their
environment, they will need to install the Force.com Toolkit plugin for Eclipse.
• It is assumed that the Java SDK 1.5 and Eclipse 3.3 for Java Developers or later
have already been installed on the client workstation. Note that these version
numbers are important.
• If the toolkit is already installed, verify that it is pointing to the correct remote site
URL and that it has been updated.
• Note that these instructions are also available on the ADN.

Time:
• 5 minutes

Instructions
1. Double click the Eclipse.exe icon to launch Eclipse
2. Click Help | Software Updates | Find and Install…
a. Select Search for new features and click Next
3. In the Update sites to visit dialog box, check the box at the bottom to
Automatically select mirrors
4. Click New Remote Site…
a. Name: Force.com Toolkit
b. URL: http://www.adnsandbox.com/eclipsetoolkit/release
c. Click OK
5. Click Finish and Eclipse will search the selected sites for the required plugins
6. In the Updates dialog box, select Force.com Toolkit
7. Click Select Required which should select the WSP tools from Europa and look
like the image below when expanded

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 49 -
8. Agree to the terms and click Next
9. Click Finish to install the plugin
10. Click OK to restart Eclipse
11. Select Window | Open Perspective | Other… and then select Force.com and
click OK

Review
1. Do you have to use the Eclipse plugin for Apex development? Is there another
option? What might affect your decision?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 50 -
Exercise 10-2: Creating a Force.com Project in Eclipse
Goal(s):
• Create an Force.com Project using the Force.com Toolkit plugin for Eclipse.

Scenario:
• Universal Containers (UC) needs to use Apex to meet several requirements. To
get their environment ready, they will need to prepare a project workspace within
Eclipse.

• Note: You must have logged into your org at least once on your computer before
you are able to create and synchronize a project in the toolkit.

Time:
• 5 minutes

Instructions
1. Double-click the Eclipse executable to launch Eclipse
2. Select File | New | Force.com Project…
3. Enter the following information on the Force.com Project dialog box:
a. Project name: Enter your username as the project name
b. Username: Enter your Salesforce username for this course
c. Password: Enter your Salesforce password for this course
d. Namespace prefix: leave blank
e. SOAP endpoint: default
f. Click Finish
4. Right-click the newly created project in the left-hand navigation pane and select
Properties.
5. In the Properties dialog box, navigate to Force.com | Apex Code, set the
Logging Level slider all the way to the right to select Profiling (maximum
verbosity), and click OK.

Review

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 51 -
1. What is the SOAP endpoint and why do we need it here? What does selecting
default mean?
________________________________________________________________
________________________________________________________________

2. When would you need to create an Force.com Project for a specific namespace?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 52 -
Exercise 11-1: Creating a Hello World Apex Class and Trigger
Goal(s):
• Create a custom Apex class to update the Hello World field on all Positions to
the value Hello World. Create a trigger to call this class when a position is
added or updated.

Scenario:
• Universal Containers wants to make sure they know the basics to create Apex
classes and triggers before they start tackling more ambitious objectives.
Tradition states that this introduction to a new programming language should be
a “Hello World” example.

Time:
• 10 minutes

Instructions
1. Login to your org and navigate to Setup | Create | Objects | Position | Custom
Fields and Relationships | New
2. Select a field Type of Text and click Next
3. Enter a Name and Label of Hello and a Length of 10
4. Click Next, Next and Save to accept the access and page layout defaults
5. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Class
6. Enter the Name HelloWorldPositionClass and click Finish
7. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
8. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Trigger
9. Enter the following information:
a. Name: HelloWorldPositionTrigger
b. Trigger Object: Position__c
c. Trigger Operations: Before Insert, Before Update
d. Click Finish
salesforce.com proprietary/confidential: customer internal use only
©2000-2007
- 53 -
10. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
11. Log in to your org and save a new position to verify that the Hello field populates
with the value World

Review
1. Can this code handle bulk updates? When would that be necessary?
________________________________________________________________
________________________________________________________________

2. Could we have written this code by only creating a trigger?


________________________________________________________________
________________________________________________________________

3. Why don’t you need an instance of the HelloWorldPositionClass to invoke its


method?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 54 -
Exercise 12-1: Creating a Standalone Delete Prevention
Trigger
Goal(s):
• Create a trigger that prevents a position from being deleted if there is an
associated job application.

Scenario:
• Previously, Universal Containers simply denied the ability to delete positions to
all employees, but recruiters are now asking for a way to delete positions if they
have no applicants. Company policy requires the retention of positions where
there were candidates who applied for the job.

Time:
• 10 minutes

Instructions
1. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Trigger
2. Enter the following information:
a. Name: PositionDeleteTrigger
b. Trigger Object: Position__c
c. Trigger Operations: Before Delete
d. Click Finish
3. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
4. Log in to your org and try to delete a position that is already associated with a job
application to verify that the trigger throws an error message

Review
1. Could this code have been written to invoke a class instead of putting the work in
the trigger itself? Why was the decision made to do it this way?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 55 -
________________________________________________________________
________________________________________________________________

2. What does the oldMap trigger context variable resolve to?


________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 56 -
Exercise 13-1: Creating an Automated Sharing Model
Goal(s):
• Complete the code to create an automated sharing model that automatically
shares positions, candidates and job applications with the relevant hiring
manager.

Scenario:
• Universal Containers (UC) wants to complete their sharing model by making
relevant recruiting records available to the appropriate hiring managers as well
as just the recruiters.

Time:
• 15 minutes

Instructions
1. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Trigger
2. Enter the following information:
a. Name: PositionSharingTrigger
b. Trigger Object: Position__c
c. Trigger Operations: After Insert, After Update
d. Click Finish
3. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
4. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Class
5. Enter the Name PositionSharingClass and click Finish
6. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
7. Log into your org and create a new position, setting the Hiring Manager to the
other user in the org

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 57 -
8. After saving the position, click Sharing and view the User and Group Sharing to
ensure that the hiring manager was automatically added

Review
1. Why is the sharing done in two distinct steps with the two separate methods?
________________________________________________________________
________________________________________________________________

2. What might be an issue with creating a lot of automatic sharing Apex triggers?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 58 -
Exercise 14-1: Creating a Test Class
Goal(s):
• Create a unit test class for an earlier exercise.

Scenario:
• Before Universal Containers can deploy their code, they will need to ensure that
all triggers and at least 75% of all code lines have unit test coverage. They will
need to write unit test for all of their code, but here we will specifically only look at
one example.

Time:
• 15 minutes

Instructions
1. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Class
a. Enter the Name HelloWorldPositionClassTest and click Finish
2. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
3. Once the code is saved and compiled, right-click your project folder | src |
unpackaged | classes folder and select Force.com | Run Tests and examine
the results in the log pane

Review
1. What keyword must all unit tests have?
________________________________________________________________
________________________________________________________________

2. A Salesforce administrator is concerned that unit tests will add junk data to the
Salesforce org database. What should you tell them?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 59 -
Exercise 15-1: Deploying Apex into Another Salesforce Org
Goal(s):
• Migrate the Apex created into another Salesforce org.

Scenario:
• Universal Containers has completed their development phase and wants to move
the code created from a development environment into production using the
Eclipse Force.com Toolkit plugin.

Time:
• 10 minutes

Instructions
1. In Eclipse, right-click your project folder, and select Force.com | Deploy to
Server…
2. On the Destination Details dialog box, enter the following information:
a. Username: Enter the username for the destination org
b. Password: Enter the password for the destination org
c. SOAP Endpoint:
https://www.salesforce.com/services/Soap/u/11.1
d. Click Next
3. In the Archive Options dialog box, check the boxes create archive snapshots of
the project and/or the destination org locally, then click Next
4. In the Deployment Plan dialog box, select the classes and triggers that you wish
to deploy and click Next (Note: You can click the Validate Deployment button to
check that your items are valid)
5. Verify the details on the Pre-Deployment Review dialog box and click Next
6. Examine the Deployment Result dialog box and click Finish

Review
1. What are the requirements for deploying into a production environment?

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 60 -
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 61 -
Exercise 16-1: Creating a Candidate Duplication Check
Goal(s):
• Create a new field, class, and trigger on the Candidate object to prevent
duplicates from being added based on a combination key structure.

Scenario:
• Universal Containers is having problems with duplicate records for candidates
entering the database. They have determined that the combination of a
candidate’s last name and email address are enough to ensure uniqueness
within the system.

Time:
• 15 minutes

Instructions
1. In your org, navigate to Setup | Create | Objects | Candidate | Custom Fields
and Relationships | New
2. Select a field Type of Formula Field and click Next
3. Enter a Label of Unique Key which defaults the Name to Unique_Key
4. Copy and paste the contents of the
CandidateUniqueKeyFormulaField.txt file into the formula text area in
the UI
5. Click Next, Next and Save to accept the access and page layout defaults
6. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Class
7. Enter the Name CandidateKeyClass and click Finish
8. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
9. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Trigger
10. Enter the following information:
a. Name: CandidateKeyTrigger

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 62 -
b. Trigger Object: Candidate__c
c. Trigger Operations: Before Insert, Before Update
d. Click Finish
11. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
12. To test the code, login to your org and create an initial candidate if there is not
one already in the org
13. Then try creating one with the same Last Name and Email fields and view the
resulting error

Review
1. What is the purpose behind the formula field? Why not just make it text?
________________________________________________________________
________________________________________________________________

2. What should be done to expose this same functionality to an external Web-to-


Candidate web application?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 63 -
Exercise 16-2: Creating a Custom Web Service for the
Candidate Duplication Check
Goal(s):
• Transform the Apex written earlier to expose the necessary method(s) as Web
Services, allowing for the same functionality to be utilized by a third party Web-
to-Candidate web application or in this case, an s-control.

Scenario:
• Universal Containers has a web tab that they use for employees to refer
candidates into the Recruiting application. In order to expose the previous
functionality, the previous code will need to be made into a Web Service.
• Note that although the referral form is being hosted in an s-control for this
exercise, it could just as well be an external web application.

Time:
• 15 minutes

Instructions
1. In Eclipse, under your project folder | src | unpackaged, right-click the
unpackaged folder and select Force.com | New Apex Class
a. Enter the Name CandidateKeyWebServiceClass and click Finish.
2. Copy the code from the appropriate file in the Exercises folder, paste it into
Eclipse, and complete the ***TODO:…*** sections as required
3. In the Salesforce UI, click Setup | Develop | S-Controls | New Custom S-
Control
a. Label: EmployeeReferral
b. S-Control Name: EmployeeReferral
c. Type: HTML
d. Copy and paste the content from the
CandidateKeyWebServiceClassSControl.txt file
e. Click Save
4. In the Salesforce UI, click Setup | Create | Tabs
5. In the Web Tabs section, click New

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 64 -
6. Select the tab layout of 2 columns with Salesforce sidebar and click Next
7. Enter the following details:
a. Tab Type: Custom S-Control
b. Tab Label: Employee Referral
c. Tab Style: Form
d. Custom Frame Height: 600
e. Click Next
8. Select the Custom S-Control EmployeeReferral [EmployeeReferral]
and click Next
9. Accept the defaults for adding the tab to the existing profiles and click Next
10. Accept the defaults for adding the tab to the existing applications and click Next
11. Click on the new Employee Referral tab
12. Complete the form, entering a candidate Last Name and Email that already
match another candidate in the system
13. After submitting the form, go to the Job Application and Candidate tabs and
notice how the system linked the new job application to the existing candidate

Review
1. What keywords do methods exposed as Web Services require?
________________________________________________________________
________________________________________________________________

2. Which access modifier must be used with Web Service methods and classes?
________________________________________________________________
________________________________________________________________

salesforce.com proprietary/confidential: customer internal use only


©2000-2007
- 65 -

You might also like