Decoding Salesforce

Decoding Salesforce

The hows and whys of Salesforce.com

Posts Tagged ‘Structure’

The World Of Apex

Hi Everyone! Sorry for the long absence from posting.

Where have I been I hear you ask, as the title of the post suggests, I’ve been lost in the “The World of Apex”, as I like to call it.

What is Apex? Apex is salesforce.com’s on demand programming language, it’s similar to Java in its syntax but differs in some important ways; you can get all the info on the force.com developer site.

For an administrator like me Apex is one of the most useful technologies that Salesforce have produced, it allows so much more flexibility when building customization onto your existing applications and building new custom applications.

Before I go into much more detail I want to get one thing clear, I am by no means a developer, I’ve done some small amounts of programming here and there, but nothing substantial, I don’t even hold a college degree, so if I can program Apex so can you!

When I started looking into Apex I was amazed at how powerful it was but found out very quickly how much hassle it can also cause. Salesforce have built what they call governor limits into Apex, which is basically a set of in built limits which you need to work within when developing; you can find more information about it here. The reason for this is that instead of running on your machine, Apex runs completely on the salesforce.com servers and they simply can’t afford that someone would write a program that could hog all the resources on their servers and cause the whole system to crumble.

Over the next few posts (I say posts because I really don’t know how often I’m going to get posting) I’m going to go through some basic concepts of Apex and provide examples of Apex triggers and classes I’ve written.

If you’ve visited the link above to the developer site you’ll also have seen information on that page regarding Visualforce. Visualforce is a HTML like markup language that allows you to restructure and build custom pages and User Interfaces for your salesforce.com implementation, currently its still in a developer preview and isn’t available to your live systems so I won’t be delving into that one just yet.

Well that’s the introductions out of the way, next post: “Getting Started”..

How to obtain a field ID

Often people ask me how to get fields IDs in order to build their custom links. I thought it would have been helpful to write a post about this. Let’s see how to get a field ID for custom and standard fields.

Custom Fields

In order to get the ID of a custom field proceed this way:

  • Click on Setup, then on Customize, select the Object you desire (e.g.: Leads) and click on Fields;
  • Click on the name of the custom field you previously created
  • Look at your browser’s address bar, you’ll see something like:
    https://emea.salesforce.com/00N20000000thpj
  • The 15 digit code that appears immediately after https://emea.salesforce.com/ is the ID of that custom field; in this case the ID of the custom field I selected is 00N20000000thpj

Easy enough, isnt’t it :)

Standard Fields

Salesforce.com provides a list of the field’s name for its standard fields, which can be found attached to the solution “How do I create custom links?” and that I decided to paste here as a quick reference:

EVENTSField TypeID
Assigned ToIDevt1_lkid
Textevt1_lkold
Subjectevt5
WhoPicklistevt2_mlktp
IDevt2_lkid
Textevt2

WhatPicklistevt3_mlktp
IDevt3_lkid
Textevt3
PrivateIsPrivate
Activity Currencyevt9
Locationevt12
Dateevt4

Timeevt13
All Day Eventevt15
Typeevt10
Show Time AsShowAs
Descriptionevt6
TASKSField TypeID
Assigned ToIDtsk1_lkid
Texttsk1
Subjecttsk5
Due Datetsk4
Statustsk4
WhoPicklisttsk2_mlktp
IDtsk2_lkid

Texttsk2
WhatPicklisttsk3_mlktp
IDtsk3_lkid
Texttsk3
Commentstsk6
Notify by Emailemail
CAMPAIGNSField TypeID
Campaign Namecpn1
Typecpn2
Statuscpn3
Start Datecpn5
End Datecpn6
Expected Revenuecpn8

Budgeted Costcpn9
Actual Costcpn10
Expected Response %cpn11
Campaign Currencycpn7
Number Sentcpn13
Activecpn16
Descriptioncpn4

LEADSField TypeID
SalutationPicklistname_salutationlea2
First Namename_firstlea2
Last Namename_lastlea2
Companylea3
Titlelea4

Lead Sourcelea5
Industrylea6
Annual Revenuelea7
CampaignIDlea20_lkid
Textlea20_lkold
Descriptionlea17
Phonelea8

Mobilelea9
Faxlea10
Emaillea11
Websitelea12
Lead Statuslea13
Ratinglea14
# of Employeeslea15

Email Opt Outlea22
Streetlea16street
Citylea16city
State/Provincelea16state
Zip/Postal Codelea16zip
Countrylea16country
Use Assignment Rulelea21

ACCOUNTSField TypeID
Account Nameacc2
Account Siteacc23
Account Numberacc5
Typeacc6
Industryacc7

Annual Revenueacc8
Account Currencyacc24
Ratingacc9
Phoneacc10
Faxacc11
Websiteacc12
Ticker Symbolacc13

Ownershipacc14
Employeesacc15
SIC Codeacc16
Billing Streetacc17street
Billing Cityacc17city
Billing State/Provinceacc17state
Billing Zip/Postal Codeacc17zip

Billing Countryacc17country
Shipping Streetacc18street
Shipping Cityacc18city
Shipping State/Provinceacc18state
Shipping Zip/Postal Codeacc18zip
Shipping Countryacc18country
Descriptionacc20

CONTACTSField TypeID
SalutationPicklistname_saluatationcon2
First Namename_firstcon2
Last Namename_lastcon2
AccountIDcon4_lkid
textcon4_lkold

Titlecon5
Departmentcon6
Birthdatecon7
Reports ToIDcon8_lkid
Textcon8_lkold
Lead Sourcecon9
Contact Currencycon21

Phonecon10
Home Phonecon13
Mobilecon12
Other Phonecon14
Faxcon11
Emailcon15
Assistantcon16

Asst. Phonecon17
Email Opt Outcon23
Mailing Streetcon19street
Mailing Citycon19city
Mailing State/Provincecon19state
Mailing Zip/Postal Codecon19zip
Mailing Countrycon19country

Other Streetcon18street
Other Citycon18city
Other State/Provincecon18state
Other Zip/Postal Codecon18zip
Other Countrycon18country
Descriptioncon20
OPPORTUNITIESField TypeID
Nameopp3
AccountIDopp4_lkid
Textopp4_lkold
Typeopp5
Lead Sourceopp6
Forecast CategoryForecastCategory

Opportunity Currencyopp16
Amountopp7
Close Dateopp9
Next Stepopp10
Stageopp11
Probabilityopp12
Campaign SourceIDopp17_lkid

Textopp17_lkold
Descriptionopp14
CONTRACTSField TypeID
AccountIDctrc7_lkid
Textctrc7_lkold
Customer Signed ByIDctrc16_lkid
Textctrc_lkold
Customer Signed TitleCustomerSignedTitle
CustomerSignedTitlectrc6
Contract CurrencyCurrencyIsoCode
Price Bookctrc17

Statusctrc15
Contract Start Datectrc5
Contract Terms(months)ctrc40
Owner Expiration Noticectrc13
Company Signed ByIDCompanySigned_lkid
TextCompanySigned_lkold
Company Signed DateCompanySignedDate

Billing Streetctrc25street
Billing Cityctrc25city
Billing State/Provincectrc25state
Billing Zip/Postal Codectrc25zip
Billing Countryctrc25country
Special TermsSpecialTerms
DescriptionDescription

CASESField TypeID
ContactIDcas3_lkid
Textcas3_lkold
Typecas5
Case Reasoncas6
Case Currencycas24

Statuscas7
Prioritycas8
Case Origincas11
Visible in Portalcas27
Subjectcas14
Internal CommentsCas15
Assignment Rulescas21

Send notification to Contactcas22
SOLUTIONSField TypeID
NameSolutionName
DetailsSolutionNote
PRODUCTSField TypeID
NameName
Product CodeProductCode
Quantity Scheduling EnabledCanUseQuantitySchedule
Product CurrencyCurrencyIsoCode
DescriptionDescription
ActiveIsActive
Product FamilyFamily

Revenue Scheduling EnabledCanUseRevenueSchedule
Quantity Schedule TypepQST
Quantity Installment PeriodpQSI
Number Of Quantity InstallmentspQSN
Revenue Schedule TypepRST
Revenue Installment PeriodpRSI
Number Of Revenue InstallmentspRSN

DOCUMENTSField TypeID
NameName
Internal Use Onlyiuo
Externally Available Imagepub
Folderpid
Descriptiondesc

Keywordskey

Questions? ;)

Salesforce’s URL Structure

UPDATE: Public apologies to Mike Schinkel, this post was inspired by Mike’s “URL Structure“. I decided to write a similar post to include the full list of known instances, mine wasn’t certainly a way to get credit for something you wrote first Mike! Sorry! :)

Finally found the structure to delete a record in SF, adding it below. Eoin

Here’s a quick introduction to understand the structure of all the URLs in Salesforce:

Instances

Salesforce’s organizations reside on multiple instances, to find out what instance you’re on, once you logged into Salesforce, have a look at the address bar; you’ll notice the URL starts with something like:

ssl – North America #0 (aka na0)
na1 – North America #1
na2 – North America #2
na3 – North America #3
na4 – North America #4
na5 – North America #5
emea – Europe, Middle East, Africa
ap – Asia, Pacific
tapp0 – Sandbox #0
tapp1 – Sandbox #1

https://xyz.salesforce.com

where xyz is the name of the instance your organization is on.

Objects’ specific URLs

Every Salesforce’s object has it’s specific URL, here are listed the links to the standard objects:

ObjectsURLsObjects’ code
Accountshttps://[instance].salesforce.com/001/o001
Contactshttps://[instance].salesforce.com/003/o003
Leadshttps://[instance].salesforce.com/00Q/o00Q
Caseshttps://[instance].salesforce.com/500/o500
Solutionshttps://[instance].salesforce.com/501/o501
Reportshttps://[instance].salesforce.com/00O/o00O
Opportunitieshttps://[instance].salesforce.com/006/o006
Campaignshttps://[instance].salesforce.com/701/o701
Productshttps://[instance].salesforce.com/01t/o01t

Basic action URLs

Use the following URLs to perform the listed operations on a specific object. Note this is fundamental to then understand how to create internal custom links.

Object’s overview page
https://[instance].salesforce.com/[object]/o
ie: https://emea.salesforce.com/500/o

Create a new record
https://[instance].salesforce.com/[object]/e?retURL=/[object_code]/o
ie: https://emea.salesforce.com/500/e?retURL=/500/o

Edit a record
https://[instance].salesforce.com/[object]/[recordID]/e?retURL=[recordID]
ie: https://emea.salesforce.com/50020000000chRD/e?retURL=/50020000000chRD

Clone a record
https://[instance].salesforce.com/[object]/[recordID]/e?retURL=[recordID]&clone=1

Delete a record
https://[instance].salesforce.com/setup/own/deleteredirect.jsp?delID=[recordID]

where:

  • [instance] is the instance’s name your organization resides on;
  • [object] is the object’s code;
  • [recordID] is the ID of the record itself.