Sunday, February 5, 2012

A comment on formatting formulas and validation rules in Salesforce


This blog is in response to a question posted on the LinkedIn Salesforce group at:
The post lost all formatting and one point being made in my comment was using indentation for clarity so this blog is being posted to help make the point.

The question posted by Katherine was:
Validation rule to make products and Schedules necessary at a certain stage
When the stage reaches X, Y, or Z, sales reps are required to enter products and schedules. Before these stages, products and schedules are not required. Does anyone know how to write a validation rule for this?

My response was:

There seems to be some question about the syntax in the sample validation rule. For those that are interested I thought it might be useful to explain what is going on in the simplest English I can. It is useful to explain from the inside out so first the CASE statement:

Salesforce compares the StageName in the sequence given in the CASE. If any of the values match the StageName then the CASE returns a 1. If none of the values match, then the CASE returns 0. This CASE returns numbers and the enclosing AND function requires a Boolean value (True or False) so the =1 is appended to the CASE statement which Salesforce compares to the result of the CASE. Note: The = sign can mean different things in Salesforce and in this case it is a comparison and not an assignment. If the case returns 1 then the result is True, otherwise it is False.

For clarity the CASE segment of code can be rewritten as (orange reflects difference from original code):

IF (

     CASE(

           StageName,
           "Perception Analysis",1,
           "Proposal/Price Quote", 1,
           "Negotiation/Review", 1,
           "Closed Won", 1,
           0
    ) = 1, True, False
) ,…

In the solution Katherine presented, the IF statement is implied in Salesforce and is shown in shorthand notation.  This type of shorthand is convenient for the programmer but is totally unreadable by anyone who has to support the code later.

In the NOT segment:
If the Opportunity is new or already has an Opportunity Line Item then the result of the NOT function is False.

With the two inner components defined then the AND operation becomes apparent.

For further clarity, the entire validation rule is rewritten with indentation. Note the comments explaining what the =1 does and the logic of the Not segment does.  Since writing comments negates any advantage of shorthand notation it is better if you don't use implied code.  I have decades of programming experience and this use of the Case statement was totally unfamiliar to me. The colored text in the following segment is only for clarity in this blog.

AND (
     
CASE
           StageName
          "Perception Analysis", 1,
         
"Proposal/Price Quote", 1,
         
"Negotiation/Review", 1,
         
"Closed Won", 1, 
          0
    ) = 1, /* Here the = sign is a comparison operator and returns True if any of the CASE Values match the StageName */


/* The next block returns True if Opportunity is neither New nor has an Opportunity Line Item */ 
     NOT (
         
OR (
               
ISNEW(),
               
HasOpportunityLineItem
          )
     )
)

Unfortunately Salesforce strips off extra spaces to save storage space so once the rule is saved you will lose the indentation. I always write complex rules like this in a text editor and use tabs to indent and then copy and paste into the rule editor. You won't see the indentation when viewing the rule but you do see it when you edit it.
I hope that adds clarity to how the validation rule works and useful tips in making your code more readable.

Teno



To find out more about our services visit us at www.quickezlearning.com 

Thursday, December 1, 2011

Relational Databases - an overly simple explanation for beginners


 Relational Databases
A relational database is a system that provides easy access to information stored in it. It is organized in such a way that the relationships can be easily explored.  Bits of information that are related to each other are grouped together.  For example, a person lives somewhere.  He or she lives in a building that has a street address in a city and state.  All of that information relates to that person but in a special way.  It shows his residential location. 
Disassembled car - a representation of relationships
You may be more familiar with relational databases than you realize.  Your phone book sorts people and businesses by last names.  The white pages are listings of everyone in the community and the yellow pages are businesses listings. Government listings are usually on green paper.  When you search for someone in the phone book by their last name, chances are you will find their relatives too. 


Another example of a relational database is a text book. It has a table of contents with related information grouped under a heading.  Textbooks sometimes have Glossaries, Indexes and bibliographies. Books can be found in libraries where they are grouped by subject or author. What are some other examples of relational databases you can think of? 
Some of the key features of electronic databases are:
·         Efficient storage and use of resources – the amounts of data stored can be voluminous and although computer technology is increasingly less expensive, reliably managing and maintaining massive amounts of data can still be costly.  Even small companies can have thousands of contacts with huge amounts of interactions such as sales calls, purchases, payments and support.

      One way to achieve efficient storage is to eliminate duplicate information. Databases use a reference (a sort of token) for duplicate data instead of copies of it.  For example, a company can have 1000 employees and each of them is at the same business address.  Instead of keeping the company name and address for each employee a database substitutes a token for that company.  We represent International Business Machines as IBM.  In fact, many people don't know who International Business Machines is but the do know IBM. The company name and address is stored once and each employee has the token.  Salesforce calls the token a record ID.  Another term for the token/ID used in databases is the key.  In either case the ID is always unique to a company and is usually in alpha-numeric form and assigned by the system to assure uniqueness. 
·         Efficient access of data – Relational databases use incredibly complex algorithms to access the data in short time. A recent Google search on “LED lighting systems” yielded 10,200,000 results in under ½ second.  Imagine trying to look up every company that made or sold LED lighting systems in the phone book.  Google can even find data when you misspell it in the search and makes recommendations.  Most database systems such as Salesforce allow you to control how you search for information.  You can limit the search to types of records and fields, fields that begin with or end with certain characteristics or words that have 1 or more unspecified characters (called wild cards) between known characters.  So even if you aren't sure of the spelling you can use what you do know to find the data you want.  Searches are the subject of another post that will be coming soon.  
·         Returning data that meets the user’s needs – in the aforementioned Google search Google tells you that it found 10,200,000 matches but only displays about a dozen.  What is the likelihood that you are going to go through more than a few pages of that data?  Google does a good job of presenting the most pertinent information first. If it presented 1000 pieces of irrelevant data first then Google probably wouldn’t be successful would they?  Most web sites have tags that help the search engines find them.  These tags are usually the keywords you will use to find a web site that has the data you are looking for.  The more matches between your keywords and the posted tags the higher the relevancy will be and likewise the higher in the list of matches returned by the database search engine.  Salesforce also allows you to add tags to improve your ability to rapidly find the data you are searching for. Searching Salesforce.com Help for tags will give you instructions on how to set up and use tags:

Tag Help in Salesforce.com
      Salesforce,com CRM is a relational database that links all activities related to contact management in a way consistent with most sales forces.  Salesforce.com has a powerful search engine that provides quick access to that data in a logical manner and allows the user to rapidly navigate through the data. It uses familiar web browsers so anyone that can surf the net can use Salesforce once they understand the underlying concepts.

To find out more about relational databases or salesforce.com go to our web-site at:
Quick EZ Learning.com


Tuesday, November 29, 2011

Getting started with Salesforce Visual Flow Designer


Salesforce Visual Flow Editor was Beta released in Spring 2011 as a simpler method for developing work flows in Salesforce.  The tool is intuitive and easy to use if you have a fundamental knowledge of programming concepts.  Visual Flow Designer requires connection to your Salesforce.com Sandbox Org, Developer Edition Org or Production Org.  The designer tool is free but using the Flows in production requires a subscription.  Your salesforce.com sales rep can give you subscription rates.


Pros and Cons
Pros Cons

  • Easy to learn
  • Simpler to learn than Apex
  • Quick Prototyping tool making it easy to evaluate business processes before committing to custom coding
  • Self Documenting. The flow details can be saved as a word document
  • Create Wizards to break data entry and sales processes into smaller chunks

  • Subscription rates can be expensive if there are more than a handful of users. For larger teams total customization may be less expensive
  • Inexperienced Programmers may have some difficulty
The Visual Flow Editor is available as a desktop application or in the cloud.  The cloud based version doesn't have all the features of the desktop version but To decide which version is appropriate for you can look at the comparison table at:
https://na3.salesforce.com/help/doc/en/vpm_designer_migration.htm


To get started with the desktop version download the Flow Designer manual at: http://www.salesforce.com/us/developer/docs/firefly/salesforce_flow_designer.pdf.   The instructions on how to download the desktop version is in the "Download the Flow Designer" section.

The cloud based Visual Flow Designer Implementation Guide is available at: https://na3.salesforce.com/help/doc/en/salesforce_vpm_implementation_guide.pdf
There you will find a brief section on "Creating a Flow" which is how to start developing the first flow.


In this sample Order Entry Flow the user is prompted for the account name and if the account exists then the user is prompted has the option of updating the account or creating a new Opportunity and adding products.  If the Account doesn't already exist in Salesforce then the user will be prompted for the new account information.  The user will not have to remember the process because they are stepped through it.


Order Entry Flow Diagram from Desktop Visual Flow Editor
If you would like training or information on using the Visual Form Designer and Flows in Salesforce or any other part of Salesforce go to our web-site at http://www.quickezlearning.com/Salesforce.html