天阔阔雪漫漫共谁同航 这沙滚滚水皱皱笑着浪荡

Salesforce Visualforce Page

|

Visualforce

  • <apex:page> creates a visualforce page; all visualforce Tags have to be enclosed in this tag.

  • <apex:page standardController="Account" showHeader="true" tabStyle="account" >

  • <apex:form> It’s a best practice to have only one < apex:form > tag in a page instead of including it many times

  • <apex:pageblock> where multiple sections can be created and fields,buttons, tables or links can be displayed. It by default inherits the standard salesforce page style.

  • <apex:pageBlockSection>
    • create a section inside a page block,
    • consists of one or more columns,(default = 2), Each component found in the body of an < apex:pageBlockSection > is placed into the next cell in a row until the number of columns is reached.
  • <apex:commandButton>
    • action that has to be executed when the button is pressed depends on the ACTION attribute specified in this tag
    • always be a child component of the < apex:form > tag.
  • <apex:pageBlockButtons> place the buttons on the top or bottom of the page. This can be achieved with the help of this tag.

  • <apex:inputField> display fields
      <apex:form id="changeStatusForm">
          <apex:pageBlock >
              <apex:pageblocksection title="Account Information">
                  <apex:inputfield value="{!account.name}"/>
              </apex:pageblocksection>
              <apex:pageblocksection title="Category Information">
                  <apex:inputfield value="{!account.type}"/>
              </apex:pageblocksection>
              <apex:pageBlockButtons >
                  <apex:commandButton value="Save" action="{!save}"/>
              </apex:pageBlockButtons>
          </apex:pageBlock>
      </apex:form>
    
  • <apex:commandlink action="{!save}" value="Save"/> This tag creates a link that helps to execute an action defined in a controller.

  • <apex:outputLink> creates a link to a URL, the body of it can be text or an image.

<apex:outputLink value="https://www.salesforce.com" id="theLink"> www.salesforce.com </apex:outputLink>

  • <apex:inputFile> ?? A component that creates an input field to upload a file. maximum file size that can be uploaded via Visualforce is 10 MB.
      <apex:page standardController="Document" extensions="documentExt">
          <apex:messages />
          <apex:form id="theForm">
          <apex:pageBlock >
              <apex:pageBlockSection >
                  <apex:inputFile value="{!document.body}"  filename="{!document.name}"/>
                  <apex:commandButton value="Save" action="{!save}"/>
              </apex:pageBlockSection>
          </apex:pageBlock>
          </apex:form>
      </apex:page>
      //Controller Class:
      public class documentExt {
          public documentExt(ApexPages.StandardController controller) {
              Document d = (Document) controller.getRecord();
              d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
          }                 
      }
    
  • <apex:inputHidden value="{!inputValue}" id="theHiddenInput"/> an input element that is invisible to the user. Use this component to pass variables from page to page.
    • eg:<apex:inputhidden value="{!account.accountNumber}"/> there is no account number displayed
  • <apex:inputSecret value="{!inputValue}" id="theSecretInput"/> An HTML input element of type password. masked input as user typed
    • eg:<apex:inputsecret value="{!account.accountNumber}"/>
  • <apex:inputText> ?? An HTML input element of type text. This component does not use Salesforce styling. Also, since it does not correspond to a field, or any other data on an object, custom code is required to use the value the user inputs.

  • <apex:inputTextarea> for a value that requires a text area.
  • eg:<apex:inputTextarea id="newDesc" value="{!contract.description}"/><p/>

  • <apex:inputCheckbox value="{!op.isprivate}"/> get user input

  • <apex:outputField value="{!opportunity.name}"/> A read-only display of a label and value for a field

  • <apex:outputLabel> A label for an input or output field. (similar to inputfield)
    • eg:

        <apex:outputLabel value="Checkbox" for="theCheckbox"/>
        <apex:inputCheckbox value="{!inputValue}" id="theCheckbox"/> 
      
  • <apex:outputText> Displays text. Displays. You can customize the appearance using CSS styles, in which case the generated text is wrapped in an HTML < span > tag. You can also escape the rendered text if it contains sensitive HTML and XML characters. This component does take localization into account. There are some example with param, toolbar, panalGrid

  • <apex:param> A parameter for the parent component. Within < apex:outputText >, there is support for the < apex:param > tag to match the syntax of the MessageFormat class in Java. Parent components can be:
    • < apex:actionFunction >
    • < apex:actionSupport >
    • < apex:commandButton >
    • < apex:commandLink >
    • < apex:outputLink >
    • < apex:outputText >
    • < flow:interview >

        <apex:page >
            <apex:outputText style="font-style:italic" value="This is {0} text with {1}."> 
                <apex:param value="my"/> 
                <apex:param value="arguments"/>
            </apex:outputText>
            <apex:outputLink value="http://google.com/search">
                Search Google
                <apex:param name="q" value="{!account.name}"/>
            </apex:outputLink>
            //when we click the link, we search account name in google
        </apex:page>
      
  • <apex:pageBlockSectionItem>
    • A single piece of data in an < apex:pageBlockSection > that takes up one column in one row.
    • An < apex:pageBlockSectionItem > component can include up to two child components.
    • If no content is specified, the column is rendered as an empty space. If one child component is specified, the content spans both cells of the column. If two child components are specified, the content of the first is rendered in the left, “label” cell of the column, while the content of the second is rendered in the right, “data” cell of the column.(like the example below)

        <apex:pageBlockSectionItem >
              <apex:outputLabel value="Account Type" for="account__type"/>
              <apex:inputText value="{!account.type}" id="account__type"/>
        </apex:pageBlockSectionItem>
      
  • <apex:dataTable> An HTML table that is defined by iterating over a set of data, displaying information about one item of data per row. The set of data can contain up to 1,000 items.
      <apex:page standardController="Lead" recordSetVar="Leads">
          <apex:pageBlock title="dataTable">
              <apex:dataTable value="{!Leads}" var="le" width="50%">
                  <apex:column value="{!le.name}"  headerValue="Name"/> 
                  <apex:column value="{!le.Phone}" headerValue="Phone"/>
                  <apex:column value="{!le.Company}" headerValue="Company"/>
              </apex:dataTable> 
          </apex:pageBlock> 
      </apex:page>
    
  • <apex:pageBlockTable>
    • A list of data displayed as a table
    • within either an < apex:pageBlock > or < apex:pageBlockSection > component
    • similar to a related list or list view in a standard Salesforce page
    • Like an < apex:dataTable>, an < apex:pageBlockTable > is defined by iterating over a set of data, displaying information about one item of data per row. The set of data can contain up to 1,000 items.

       <apex:page standardController="Lead" recordSetVar="Leads">
           <apex:pageBlock title="pageBlockTable">
               <apex:pageBlockTable value="{!Leads}" var="le">
                   <apex:column value="{!le.name}"/> 
                   <apex:column value="{!le.Phone}"/>
                   <apex:column value="{!le.Company}"/>
               </apex:pageBlockTable> 
           </apex:pageBlock> 
       </apex:page>
       //this example shows all leads in a table with name, phone and company fields
      
  • <apex:column> must always be a child of an < apex:dataTable > or < apex:pageBlockTable > component.

  • <apex:facet> A placeholder for content that is rendered in a specific part of the parent component, such as the header or footer of an < apex:dataTable >.(it’s like the column name). An < apex:facet > component can only exist in the body of a parent component if the parent supports facets.
      <apex:page standardController="Account">
          <apex:pageBlock title="Contacts">
              <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">
                  <apex:column>
                      <apex:facet name="header">Name</apex:facet>
                              {!contact.Name}
                  </apex:column>
                  <apex:column>
                      <apex:facet name="header">Phone</apex:facet>
                              {!contact.Phone}
                  </apex:column>
              </apex:dataTable>
          </apex:pageBlock>
      </apex:page>
    
  • <apex:tabPanel> A page area that displays as a set of tabs. When a user clicks a tab header, the tab’s associated content displays, hiding the content of other tabs.

  • <apex:tab> A single tab in an < apex:tabPanel>. The component must be a child of a < apex:tabPanel >.
      <apex:page id="thePage">
          <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel">
              <apex:tab label="One" name="name1" id="tabOne">content for tab one</apex:tab>
              <apex:tab label="Two" name="name2" id="tabTwo">content for tab two</apex:tab>
          </apex:tabPanel>
      </apex:page>
    
  • <apex:toolbar> A stylized, horizontal toolbar that can contain any number of child components. By default, all child components are aligned to the left side of the toolbar. Use an < apex:toolbarGroup > component to align one or more child components to the right.

  • <apex:toolbarGroup> A group of components within a toolbar that can be aligned to the left or right of the toolbar.
      <apex:page id="thePage">
          <apex:toolbar id="theToolbar">
              <apex:outputText value="Sample Toolbar"/>
              <apex:toolbarGroup itemSeparator="line" id="toobarGroupLinks">
                  <apex:outputLink value="http://www.salesforce.com">salesforce </apex:outputLink>
                  <apex:outputLink value="http://developer.salesforce.com">apex developer network </apex:outputLink>
              </apex:toolbarGroup>
              <apex:toolbarGroup itemSeparator="line" location="right" id="toobarGroupForm">
              <apex:form id="theForm">
                      <apex:inputText id="theInputText">Enter Text</apex:inputText>
                      <apex:commandLink value="search" id="theCommandLink"/>
                  </apex:form>
              </apex:toolbarGroup>
          </apex:toolbar>
      </apex:page>
    
  • <apex:pageMessage> This component should be used for presenting custom messages in the page using the Salesforce pattern for errors, warnings and other types of messages for a given severity.
    • e.g.: <apex:pageMessage summary="This pageMessage will always display. Validation error messages appear in the pageMessages component." severity="warning" strength="3" />
  • <apex:panelBar>
    • A page area that includes one or more < apex:panelBarItem > tags that can expand when a user clicks the associated header.
    • An < apex:panelBar > can include up to 1,000 < apex:panelBarItem > tags.
    • When an < apex:panelBarItem > is expanded, the header and the content of the item are displayed while the content of all other items are hidden. When another < apex:panelBarItem > is expanded, the content of the original item is hidden again.

        <apex:page >
            <apex:panelBar >
            <apex:panelBarItem label="Item1">data1</apex:panelBarItem>
            <apex:panelBarItem label="Item2">data2</apex:panelBarItem>
                <apex:panelBarItem label="Item3">data3            </apex:panelBarItem>
            </apex:panelBar>
        </apex:page>
      
  • <apex:panelBarItem>

  • <apex:panelGrid> each component found in the body of the < apex:panelGrid > is placed into a corresponding cell in the first row until the number of columns is reached. At that point, the next component wraps to the next row and is placed in the first cell.
    • eg: it shows like: (line one): First Second Third; (line two): Fourth

        <apex:page >
            <apex:panelGrid columns="3" id="theGrid">
                <apex:outputText value="First" id="theFirst"/>
                <apex:outputText value="Second" id="theSecond"/>
                <apex:outputText value="Third" id="theThird"/>
                <apex:outputText value="Fourth" id="theFourth"/>
            </apex:panelGrid>
        </apex:page>
      
  • <apex:panelGroup> A container for multiple child components so that they can be displayed in a single panelGrid cell. An < apex:panelGroup > must be a child component of an < apex:panelGrid >.
    • eg: it shows like: (line one): First Second ThirdFourth

        <apex:page >
            <apex:panelGrid columns="3" id="theGrid">
                <apex:outputText value="First" id="theFirst"/>
                <apex:outputText value="Second" id="theSecond"/>
                <apex:panelGroup id="theGroup">
                    <apex:outputText value="Third" id="theThird"/>
                    <apex:outputText value="Fourth" id="theFourth"/>
                </apex:panelGroup>
            </apex:panelGrid>
        </apex:page>
      
  • <apex:repeat> An iteration component that allows you to output the contents of a collection according to a structure that you specify. The collection can include up to 1,000 items.
    • if used within an < apex:pageBlockSection > or < apex:panelGrid > component, all content generated by a child < apex:repeat > component is placed in a single < apex:pageBlockSection > or < apex:panelGrid > cell.
    • attributes:
      • first: For example, if you did not want to display the first two elements in the set of records specified by the value attribute, set first=”2”.
      • value: The collection of data that is iterated over.
      • var: The name of the variable that represents the current item in the iteration.
        <apex:page controller="repeatCon" id="thePage">
            <apex:repeat value="{!strings}" var="string" id="theRepeat">
                <apex:outputText value="{!string}" id="theValue"/> 
                <br/>
            </apex:repeat>
        </apex:page>
        //Controller class:
        public class repeatCon {
            public String[] getStrings() {
                return new String[]{'ONE','TWO','THREE'};
            }
        }
      
  • <apex:detail> The standard detail page for a particular object, as defined by the associated page layout for the object in Setup. eg:<apex:detail subject="{!account.ownerId}" relatedList="false" title="false"/>

  • <apex:variable>
    • A local variable that can be used as a replacement for a specified expression within the body of the component.
    • reduce repetitive and verbose expressions within a page.
    • does not support reassignment inside of an iteration component,
    • an example: output all accounts in the collection using loop in visualforce page

        <apex:page controller="repeaterCon">
            <apex:variable value="{!1}" var="rowNum"/>
            <apex:repeat value="{!collection}" var="row">
                {!rowNum}-{!row}<br/>
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
            </apex:repeat>
        </apex:page>
        //custom controller:
        public class repeaterCon {
        public List<String> collection {
                get {
                    if (collection == null) {
                        collection = new List<String>();
                        for (Account a : [SELECT ID, Name FROM 
                            Account  LIMIT  10]) {
                            collection.add(a.Name);
                        }
                    }
                    return collection;
                }
                private set;
            }
        }
      
  • <apex:stylesheet> A link to a stylesheet that can be used to style components on the Visualforce page.
    1. create a css file eg: CssExample.css
    2. upload this file as a static resource: setup-develop-static resource, new+public
    3. write visualforce page like:

       <apex:page standardstylesheets="false" showheader="false">
           <apex:stylesheet value="{!$Resource.CssExample}"/>
           <h1> This text is displayed using CSS </h1>
       </apex:page>
      
  • <apex:sectionHeader title="One of Your Opportunities" subtitle="Exciting !"/> A title bar for a page. In a standard Salesforce page, the title bar is a colored header displayed directly under the tab bar.

  • <apex:relatedList> It is going to display a list of Salesforce records that are related to a parent record with a lookup or master-detail relationship.
      <apex:page standardController="Account">
          <apex:pageBlock >
          You're looking at some related lists for {!account.name}:
          </apex:pageBlock>
          <apex:relatedList list="Opportunities" />
          <apex:relatedList list="Contacts">
              <apex:facet name="header">Titles can be overriden with facets</apex:facet>
          </apex:relatedList>
          <apex:relatedList list="Cases" title="Or you can keep the image, but change the text" />
      </apex:page>
    
  • <apex:listViews> The list view picklist for an object, including its associated list of records for the currently selected view. ?? <apex:ListViews type="Case" /> shows a picklist for cases including all cases, my cases, etc, and details of specified cases.

  • <apex:enhancedList> Enhanced lists are used when you want to display a specific list view for a standard or custom object, rather than having all list views available for the user to select.
    • Listid = “15 digit” to reference to a custom list view

        <apex:page>
            <apex:enhancedList type="Account" height="300" rowsPerPage="10" id="AccountList" />
            <apex:enhancedList type="Lead" height="300" rowsPerPage="25"
                id="LeadList" customizable="False" />
        </apex:page>
      
  • <apex:actionStatus> displays the status of an AJAX update request; display some gif (graphic Interchange Format), which shows to user that their request is in progress.
  • <apex:actionSupport> A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover. only provides support for invoking controller action methods from other Visualforce components Eg: ` ` the decrementCounter is defined in controller

  • <apex:actionFunction> A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. An < apex:actionFunction > component must be a child of an < apex:form > component. defines a new JavaScript function which can then be called from within a block of JavaScript code. See examples here

  • <apex:actionPoller>
    • A timer that sends an AJAX update request to the server according to a time interval that you specify.
    • if an < apex:actionPoller > is ever re-rendered as the result of another action, it resets itself.
    • avoid using this component with enhanced lists.
    • e.g. : counter++ every 15 seconds

        <apex:page controller="exampleCon2">
            <apex:form >     
                <apex:outputText value="Watch this counter: {!count}" id="counter"/>
                <apex:actionPoller action="{!incrementCounter}" rerender="counter" interval="15"/>     
            </apex:form>
        </apex:page>
        //Controller Class:
        public class exampleCon2 {  
            Integer count = 0;                         
            public PageReference incrementCounter() {
                count++;
                return null;
            }                  
            public Integer getCount() {
                return count;
            }
        }
      
  • <apex:actionRegion> An area of a Visualforce page that demarcates which components should be processed by the Force.com server when an AJAX request is generated. Only the components in the body of the < apex:actionRegion > are processed by the server, thereby increasing the performance of the page. it does not define what area(s) of the page are re-rendered when the request completes. To control that behavior, use the rerender attribute on an < apex:actionSupport >,< apex:actionPoller >, < apex:commandButton >, < apex:commandLink >, < apex:tab >, or< apex:tabPanel > component.
      <apex:actionRegion >
          <apex:inputField value="{!opportunity.stageName}" id="stage">
              <apex:actionSupport event="onchange" rerender="thePageBlock" status="status"/>
          </apex:inputField>
      </apex:actionRegion>
    
  • Referencing a Static Resource in Visualforce Pages
      <apex:image url="{!$Resource.TestImage}" width="50" height="50"/>
      <apex:includeScript value="{!$Resource.MyJavascriptFile}"/>
     <apex:image url="{!URLFOR($Resource.TestZip,'images/Bluehills.jpg')}" width="50" height="50"/>
    
  • Message Class
    • If your application uses a custom controller or extension, you must use the message class for collecting errors.
    • ApexPages.severity is the enum that is determines how severe a message is
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL, 'my error msg');
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity, summary, detail);
      
  • page reference class (when using custom controller or controller extension)
    • Page.existingPageName By referring to a page in this way, the platform recognizes that this controller or controller extension is dependent on the existence of the specified page and will prevent the page from being deleted while the controller or extension exists.
    • PageReference pageRef = new PageReference('partialURL'); For example, setting ‘partialURL’ to’/apex/HelloWorld’, setting ‘partialURL’ to ‘/’ + ‘recordID’
      • (less preferable!!) because the PageReference is constructed at runtime, rather than referenced at compile time. Runtime references are not available to the referential integrity system. Consequently, the platform doesn’t recognize that this controller or controller extension is dependent on the existence of the specified page and won’t issue an error message to prevent user deletion of the page.
    • PageReference pageRef = new PageReference('http://www.google.com'); creates a page reference for an external URL
    • PageReference pageRef = ApexPages.currentPage(); instantiate a PageReference object for the current page with the currentPage ApexPages method.
  • Select Option Class:
    • A SelectOption can also be displayed in a disabled state, so that a user cannot select it as an option, but can still view it.
    • exanple: where values is the String that is returned to the controller if the option is selected by a user,label is the String that is displayed to the user as the option choice, and Disabled is a Boolean that, if true, specifies that the user cannot select the option, but can still view it.
        SelectOption option = new SelectOption(value, label, isDisabled);
      
  • Standard Controller Class: The only time it is necessary to refer to a StandardController object is when defining an extension for a standard controller. StandardController is the data type of the single argument in the extension class constructor. ApexPages.StandardController sc = new ApexPages.StandardController(sObject);

Web Technologies + DB/SQL + Linux/unix

|

index:

1. web
2. algorithm
3. DB/SQLy
4. Linux/unix
5. OS
6. OOD
7. VCS - Git
8. System Design

web tech

  • The communication protocols,
  • languages/APIs,
  • other mechanisms that enable the internet to function.

  • HTTP,
  • Browsers,
  • DNS,
  • HTML/XML,
  • AJAX, etc
  • routers
    • Routers are small electronic devices that join multiple computer networks together via either wired or wireless connections.
    • By maintaining configuration information in a part of memory called the routing table, routers also can filter both incoming or outgoing traffic based on the addresses of senders and receivers.
  • Cookies
  • DNS: domain name servers,
  • Load balancers,
  • firewalls,
  • Knowledge of Front End programming languages (HTML, CSS, JavaScript),
  • protocols (HTTP and TCP/IP) and
  • general understanding of how the internet works.

1. HTTP

  1. HTTP/1.1
    • stands for Hypertext Transfer Protocol.
    • stateless, (does not keep state between different message exchanges.)
    • application-layer protocol for communicating between distributed systems
    • is the foundation of the modern web.
    • allows for communication between a variety of hosts and clients
    • support a mixture of network configurations
    • usually takes place over TCP/IP
    • port:80. https port:443
    • 1.1 new features: persistent connections, chunked transfer-coding and fine-grained caching headers
    • HTTP allows servers to redirect a client request to a different location.
      • If content has moved to a different URL or domain name, redirection can be used to avoid breaking old URLs or bookmarks.
      • It is possible to convert a POST request to a GET request using redirection.
    • communication between a host and a client occurs, via a request/response pair
      • client initiates an HTTP request message and get a http response in return
    • http1, url, status code, verbs, ajax,Request and response headers
    • http2, connections,Caching, connection handling and authentication.

2. utf-8 vs. unicode

  1. Unicode assigns each character a unique number, or code point.
  2. UTF-8 is a character encoding - a way of converting from sequences of bytes to sequences of characters and vice versa.
  3. UTF is a type of encoding that uses a variable number of bytes per character, UTF-8 means the unit size is 8 bits. The standard then defines a few of these bits as flags: if they’re set, then the next unit in a sequence of units is to be considered part of the same character.
  4. UTF-8 encodes each valid code points in Unicode using one to four 8-bit bytes.[9] Code points with lower numerical values, which tend to occur more frequently, are encoded using fewer bytes.
  5. Communications protocols such as HTTP tend to work best with UTF-8, as the unit size in UTF-8 is the same as in ASCII,.
  6. UTF-8 is a particular way of encoding Unicode.

3. What happens after you typed a URL in your browser and pressed return key?

  • goal:You type in the URL and hit go. The browser needs to translate that URL www.somesite.com into an IP address so it knows what computer on the internet to connect to
  • pre/assumption: In an extremely rough and simplified sketch, assuming the simplest possible HTTP request, no proxies, IPv4 and no problems in any step:

  • So your browser will see if it already has the appropriate IP address cached away from previous visits to the site.
  • If not, it will make a DNS query to your DNS server (might be your router or your ISP’s DNS server)
  • Once your browser knows what IP to use, it will connect to the appropriate webserver and ask for the page.
  • The webserver then returns the requested page and your browser renders it to the screen.

4. TCP/IP

  1. Host A sends a TCP SYNchronize packet to Host B

  2. Host B receives A’s SYN

  3. Host B sends a SYNchronize-ACKnowledgement

  4. Host A receives B’s SYN-ACK

  5. Host A sends ACKnowledge

  6. Host B receives ACK.
  7. TCP socket connection is ESTABLISHED.

graph here

three frames.

  • SYN: This is the synchronization phase. This TCP segment sets the sequence number to be used for the upcoming data transfer.

  • SYN-ACK: The reply from the remote host does two things: Verifies the sequence number that will be used. Acknowledges the original request.

  • ACK: This data is sent from the originating host, and acknowledges the sequence number and the acknowledgement from the targeted host.

5. how Cookies are used by web companies both to the advantage of the user and the company itself (e.g. ads).

  1. Cookies are pieces of information generated by a Web server and stored in the user’s computer, ready for future access. Cookies are embedded in the HTML information flowing back and forth between the user’s computer and the servers. Cookies were implemented to allow user-side customization of Web information.
  2. benifits/advantage/pros
    • Cookies allow a web application to respond to you as an individual.
    • By gathering and remembering information about your preferences, the web application can tailor its operation to your needs, likes and dislikes.
    • cookies allow web developers to create better web applications,which are more personal, easier to use.
    • Conveniency: Cookies can make filling out address forms quick and efficient. Most online shopping websites nowadays allow cookies for address and email information
    • Personalization: Amazon uses cookies to offer you related products, Google uses cookies to better understand your searches,
    • Effective Advertising
    • Ease of Control: It is actually really easy to manage your cookies if you know how. Most browsers make it easy for you to clear your browsing history.
  3. disvantage/cons
    • Privacy: The main concern for most users is privacy. Cookie enabled web browsers keep track of all the websites you have visited. This means that with permission, third parties can access the information stored by these cookies. These third parties can be advertisers, other users, or even the government in some cases.
    • Security: Cookie security is a large problem. The concern is that many security holes have been found in different browsers. Some of these holes were so serious that they allowed malicious webmasters to gain access to users’ email, different passwords, and credit card information.
    • Secrecy: Although third party cookies can be blocked through your browser settings, most people don’t have the technical expertise to do this. Most browsers purposely make it difficult to find this setting in order to prevent you from turning them off. No cookies mean no data, which in turn means less money.

8. HTTP pipelining/persistence,

ref: pipelining

  • HTTP pipelining HTTP pipelining is a feature of HTTP 1.1 persistent connections. It is a technique in which multiple HTTP requests are sent on a single TCP connection without waiting for the corresponding responses.
  • server-side: making sure that network buffers are not discarded between requests
  • proxies: Most HTTP proxies do not pipeline outgoing request
  • HTTP is based on TCP, and one of TCP’s guarantees is ordered delivery. This means that all of the requests sent out on the same socket, will be received in that order on the server.
  • HTTPS pipelining is also possible with secure HTTP connections and it gives an even greater degree of speed because of the extra needed SSL/TLS handshakes.
  • Which browsers support HTTP pipelining? (And how to enable it)
    • Google Chrome: No
    • Safari: No
    • Internet Explorer: No
    • Opera: Yes
    • Firefox: Yes, but you need to enable it by following the below steps.
  • HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses

  • why http pipelining: TCP/IP packets can be reduced. several HTTP requests could fit into a single packet. What this means is that you can get much faster page loads by using HTTP pipelining.

Algorithm

1. clarify

  1. are there any time or space complexity requirements?
  2. is the range of these values limited in some way.
    • ex:If the set fit memory, but my input not fit the memory, I can just process it into chunks. I put it in a set, accumulated set. If we can do it parallel, then it’s kind of the same thing. so we have multiple computers each not particular processing each bit of the input. each one producing a set of complement this bit has seen each computer is testing this program in the right order when I merge them, we can say oh, those tow are correctly. when I have four in this computer and four in that computer, I could merge them and I would need to be careful that I reconcile them. but other than that, I think that would be the only consideration
  3. How about … (corner case, edge case)?

2. Algorithm

  1. think out loud, say your thought
  2. data structure
  3. hashmap
    • hash function,
    • load factor: 1-0 resizing to 2*capacity when the number of element inserted in array > capacity * load factor
    • collision:
      • linear probing, move to the next item one by one
      • seperate chaining, linkedlist, worst case O(n)

        3. test your solution

        (corner case, edge case)

4. Classic problems

np, co-np, np completeness, recursion(gcd,extended gcd, union-find’s find)

  • Decision Problem A decision problem is a problem whose answer is YES or NO
  • P (Polynomial time) The class P is the set of all decision problems that can be solved in polynomial time in the size of their encoding (ie. polynomial number of operations)
  • NP (Nondeterministic Polynomial time) The set of all decision problem such that if the answer is YES then there is a certificate of validity that can be checked in polynomial time in the size of their input (a yes answer for a decision problem can be verified in polynomial time)
  • co-NP The set of all decision problem such that if the answer is NO then there is a certificate of validity that can be checked in polynomial time in the size of their input (a no answer for a decision problem can be verified in polynomial time)
  • NP-Completeness(CNF-SAT, cli)
    • A decision problem P is NP-Complete if two conditions are satisfies:(1) It is NP; (2) Every other problem P’ in NP is polynomially reducible to P.
    • A problem is NP-Hard iff a polynomial-time solution for it would imply a polynomial-time solution for every problem in NP.
    • A problem is NP-Complete iff it is NP-Hard and it is in NP itself.
  • Theorem1: P is a subset of NP. Also, P is a subset of co-NP
  • example: (algorithms)[http://www.cse.iitd.ernet.in/~naveen/courses/CSL630/all.pdf]
    • np complete:
      • 3set
      • 3SAT
      • TSP: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?
      • RUDRATA cycle: Given a graph, find a path that contains each vertex exactly once.
      • independent set/clique: G=(V,E), S belongs to V, S is independent set if there are no edges between vertices in S.
      • knapsack: Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible
    • npall np
      • Travelling salesman problem (decision version)
      • Independent set problem
      • Boolean satisfiability problem (SAT)
      • Vertex cover problem
      • Knapsack problem
      • Hamiltonian path problem: a path in an undirected or directed graph that visits each vertex exactly once.
    • np-hard: Sodoku – Does a given Sodoku puzzle have a solution?
      • Partition: partition problem is the task of deciding whether a given multiset S of positive integers can be partitioned into two subsets S1 and S2 such that the sum of the numbers in S1 equals the sum of the numbers in S2.
    • p
      • 2SAT, HORN SAT
      • MINIMUM SPANNING TREE
      • INDEPENDENT SET on trees
      • EULER PATH: Given a graph, find a path that contains each edge exactly once.

Databases/SQL

Data modeling fundamentals, database architecture/efficiency, SQL commands/syntax, complex query design, etc

  • A well-structured database:
    • Maintains data accuracy and integrity.
    • Provides access to the data in useful ways.
    • Saves disk space by eliminating redundant data.
  • steps:
    • Understanding the purpose of your database, not only at beginning of design process, but keep this in mind throughout the process.
    • talk to the people who will use it, find out what data they need to use
    • Analyze business forms, such as invoices, timesheets, surveys
    • to check that if we need to Comb through any existing data systems (including physical and digital files)
  • sql: Structured Query Language is the basic way of asking a database server to talk to you.
    • foreign key
      • A FOREIGN KEY is a key used to link two tables together.
      • A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.
    • union: merges the contents of two structurally-compatible tables into a single combined table. omit duplicate records
    • UNION ALL: same…include duplicate records. performance of UNION ALL will typically be better than UNION.
    • A primary key is usually used as the index for a particular table — a value that the table can depend upon to be a reliable unique value in every row.
    • joinneed to search across multiple tables simultaneously, a join can help make that happen
      • Equijoins are easy to specify and easy to validate
    • difference between ‘=’ and ‘LIKE’? LIKE allows partial matching / use of wildcards, while = checks for exact matches.
    • COUNT() get the quantity of results from a query. ex SELECT COUNT(*) AS NumberOfOrders FROM Orders
    • INSERT submits data into a database as a new row,
    • DROP removes a table from a database or a database from a server.
    • UPDATE allows values to be modified where they meet specific criteria
    • example: select case when null is null then 'Yup' else 'Nope' end as Result;
    • Group by summarizing
    • Order by specify the sort criteria.
    • Join
      • (INNER) JOIN: Returns records that have matching values in both tables
      • LEFT (OUTER) JOIN: Return all records from the left table, and the matched records from the right table
      • RIGHT (OUTER) JOIN: Return all records from the right table, and the matched records from the left table
      • FULL (OUTER) JOIN: Return all records when there is a match in either left or right table
    • neseted query a nested query can be replaced with a JOIN, allowing for much more efficient use of resources. difficult to troubleshoot and even harder to manage
    • sql injection SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1; or SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""="" when we type “” or “”=”” as username and password.
    • answer to sql injection input sterilization. One of the main answers to SQL Injection, input sterilization allows the database to selectively ignore data coming in from an input field and strip out non-required data.
    • Flat File A flatfile is a catch-all term used for concepts like Comma Separated Values (.csv).
  • noSQL VS. Relational DB
    • Does not follow any order vs. organized and structured
    • Very Good scalability vs. average
    • Limited as no join clause when query vs. SQL
    • K-V pairs, in json vs. data and relationship stored in different tables
  • DB schema: A database schema is a way to logically group objects such as tables, views, stored procedures etc. Think of a schema as a container of objects.
  • What is Replication? Database replication allows for real-time automated backups between multiple database servers. This allows for the creation of either a fall-over server, or warm backup for use in case the main server goes down.
  • XML? Extensible Markup Language (XML) is a fast way to display data that not only conforms to a structure that can be read by machines, but is also easily understandable by humans.
  • DB normalization Once you have a preliminary design for your database, you can apply normalization rules to make sure the tables are structured correctly. Think of these rules as the industry standards.
  • index make index on
    • Although indexes speed up data retrieval, they can slow down inserting, updating, and deleting, since the index has to be rebuilt whenever a record is changed.
    • postgresql: index-default, index-gin(index inside json)read more, update less: index,
  • complex query :
    • break up the query into managable parts, Complex queries can sometimes just be a collection of simple queries.
    • Beware of mixed levels of aggregation: If you have to put monthly, quarterly and year-to-date values in the same result set, you’ll need to calculate them separately in queries grouped on different values.
    • when to UNION: Having to include items from different tables in different rows is an obvious use.
    • Enforcing the same style over tables, columns, etc. helps the readability a lot too.
    • Enforcing the same style over queries
    • Where possible, I generate test data to verify that boundary conditions and other exceptional cases don’t cause my query to fail.
      • Test each of the queries in a union query separately.
      • Test subqueries separately.
      • Test complex expressions separately.
      • Look at raw data before I apply built-in functions to it.

Conclusion To write an efficient query, you need to know how much data you have to acquire and where it’s going to be. You also need to know what options you have for acquiring the data and how much effort you are going to waste visiting data that you don’t need so that you can decide the best order for visiting tables.

For complex queries the best way to design the query is to start by drawing a diagram of all the tables involved, showing the joins between the tables, indicating the volume of data involved, and describing the indexes that allow you to get from one table to the next. A diagram of this sort will make it much easier to understand the efficiency of the possible paths that your query could take through the tables.

Linux/Unix

Must be comfortable working in a Linux environment (as a user, not an admin) and will be expected to have a good working knowledge of user­-level Linux commands, shell scripting, regular expressions, etc.

  • grep pipeline regard the input
  • auex
  • sed: Strean EDitor, eg: replace all occurrences of string1 in current directory with string2
    • sed is the stream editor, in that you can use | (pipe) to send standard streams (STDIN and STDOUT specifically) through sed and alter them programmatically on the fly    - eg:sed -i -e 's/few/wt/g' afile.txt
      • s/: subsitute the found expression ‘few’ with ‘wt’ in afile.txt.
      • /g stands for “global”, meaning to do this for the whole line. If you leave off the /g (with s/few/asd/, there always needs to be three slashes no matter what), only the first few will be changed to wt.
      • -i option is used to edit in place on the file hello.txt.(in-place: save back to the original file))
      • -e option indicates the expression/command to run, in this case s/.
      • Note: It’s important that you use -i -e to search/replace. If you do -ie, you create a backup of every file with the letter ‘e’ appended.
      • Note2: On OS X you can’t use sed -i -e since the extension of the backup file would be set to -e, so we need to use sed -i '' -e 's/foo/bar/' target.file
          few people
          ==>
          wt people
        

               - Replace any of foo, bar or baz with foobar: sed -Ei 's/foo|bar|baz/foobar/g' file

  • or, we just using perl -i -pe 's/vy/xy/g' ./* , but this one will fail for file names ending in or space.
  • cat: cat file1 file2 prints the content of file1 followed by file2 to stdout.
  • tee
  • top usage of your machine
  • history
  • touch
  • tar cvf archive_name.tar dirname/
  • grep -i "the" demo_file Search for a given string in a file(-r recursively)/$ grep -A 3 -i "example" demo_text Print the matched line, along with the 3 lines after it.
  • find -iname "MyCProgram.c" find file
  • ssh -l jsmith remotehost.example.com login to remote host
  • Remove duplicate lines using awk
  • delete lines that sum to zero: awk '{s=0; for (i=3;i<=NF;i++) s+=$i; if (s!=0)print}' infile > outfile
  • $ awk '{print}' employee.txt: By default Awk prints every line of the file
  • awk '/manager/ {print}' employee.txt : Print the lines which matches with the given pattern(matches with the ‘manager’).
  • awk '{print NR,$0}' employee.txt : Use of NR built-in variables (Display Line Number)
  • awk '{print $1,$NF}' employee.txt : $1 means the 1st col, $NF means the last field
  • awk 'NF > 0' geeksforgeeks.txt: To print any non empty line if present. See more examples at Geeksforgeeks
  • su do /su -username: Switch to a different user account using su command.
  • gzip / gzip -d
  • ps
    • ps -aux|grep 11338(pid):
      • a = show processes for all users
      • u = display the process’s user/owner
      • x = also show processes not attached to a terminal
    • sort processes by their port numbers in increasing order (no solutions found). sort processes by current CPU/memory usage can be implemented using ps aux | sort -r or -m
  • src scp root@10.134.49.138:/root/yangxiaolu/vr_validation.jar .scp root@对 地址:/ 件路径+名字 【.(放当前 录) /search(放某 录)】
  • mkdir
  • vim
  • chmod
  • ifconfig
  • man crontab / manue, Display the man page of a specific command.
  • tail filename.txt Print the last 10 lines of a file by default.
  • wget uri : download uri file
  • netstat -nap grep (searchhub端 号)【显 进程的所有信息】
  • curl localhost:8080 显示页面内容,一般不显示头, curl --heat url 显示头, curl -i url 显示所有内容
  • pwd
  • cd
  • ls -la
  • uname -a
  • cat /etc/rel
  • more /etc/passwd in xy
  • id/ pid
  • env
  • env more
  • df -h / df -h ./ df -h awk ‘{print $4}’ sort -nr
  • permission, owner, member in my group, others
  • chmod 777
  • ll -a grep -i mar/ ll -a grep “Mar”>username
  • netstat -ap grep -i listen more
  • hohup df -h &
  • swapon
  • free -h
  • at ^c
  • I/O Redirection
    • Standard Output: Most command line programs that display their results do so by sending their results to a facility called standard output.
      • ls > file_list.txt: the ls command is executed and the results are written in a file named file_list.txt. Since the output of ls was redirected to the file, no results appear on the display.
      • ls >> file_list.txt: If you want the new results to be appended to the file, use “»” like this(use ‘>’, we will overwrite file_list.txt)
    • Standard Input: Many commands can accept input from a facility called standard input. To redirect standard input from a file instead of the keyboard, the “<” character is used        - sort < file_list.txt: we used the sort command to process the contents of file_list.txt. The results are output on the display since the standard output is not redirected in this example. We could redirect standard output to another file
    • Pipes: connect multiple commands together with what are called pipes. With pipes, the standard output of one command is fed into the standard input of another.
             

OS

OS(semophores, newtexts, lock, process, thread, resource allocation, context switching, corcurrency)

  • process vs. thread: threads are a part of a process, i.e. a process may contain one or more threads, but a thread cannot contain a process.
  • Starvation: one or more threads denied resources
  • semophores: Synchronized counting variable a semaphore is a variable or abstract data type that is used for controlling access, by multiple processes, to a common resource in a parallel programming or a multi user environment
    • Two operations: P() and V()/p: while value = 0, sleep; decreame value/v:Increment value; If there are any threads sleeping waiting for value to become non-zero, wakeup at least 1 thread
  • lock
  • resource allocation
  • context switching: In computing, a context switch is the process of storing and restoring the state of a process or thread so that execution can be resumed from the same point at a later time. CS saves this return address to the TCB(thread control block)
  • synchronization mechanism to avoid race conditions by ensuring exclusive execution of critical sections
  • corcurrency
  • fork(): After a new child process created, both processes will execute the next instruction following the fork() system call.
  • What is deadlock?
    • permanent blocking of threads
    • Deadlock is a situation when two or more processes wait for each other to finish and none of them ever finish.
    • One real Life example would be: “a person says he always lies”.
    • If he’s a liar, he’s telling the truth. Here truth and lie can be considered two processes that don’t let each other finish
    • Another example to which you all can relate. “You need experience to get a job and a job to get experience”
  • What are the necessary conditions for deadlock?
    • Mutual Exclusion: There is s resource that cannot be shared.
    • Hold and Wait: A process is holding at least one resource and waiting for another resource which is with some other process.
    • No Preemption: The operating system is not allowed to take a resource back from a process until process gives it back.
    • Circular Wait: A set of processes are waiting for each other in circular form.
  • How to break the deadlock?
    • The above are necessary but not sufficient conditions, even if all the conditions exist the system may or may not be in a deadlock, but if it’s missing then deadlock won’t happen.

Programming/OO

You will be asked to write some code in at least one of the interviews (in your preferred language). Syntax is not as important as structured thinking, but proper syntax never hurts. Object oriented theory and concepts may also be covered

  1. Abstraction: The process of picking out (abstracting) common features of objects and procedures.

  2. Class:
    1. A category of objects. The class defines all the common properties of the different objects that belong to it.
    2. A class, in the context of Java, are templates that are used to create objects, and to define object data types and methods.
  3. Encapsulation: // [ɪn,kæpsə’leʃən]
    1. Encapsulation enable programmers to hide the data of one class from another class. This is needed to protect the normal behavior of one class. We implemented it using key words including public, private, and protect
    2. Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.
    3. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class
  4. Inheritance: // [in’heritəns] a feature that represents the “is a” relationship between different classes. Inheritance in OOP enable a programmer to extend the capabilities of class without changing the class.

  5. Interface: the languages and codes that the applications use to communicate with each other and with the hardware.

  6. Object: a self-contained entity that consists of both data and procedures to manipulate the data.

  7. Polymorphism: // [,pɔli’mɔ:fizm]
    1. Subclasses of a class can define their own unique behaviors and yet share some of the same functionality of the parent class.
    2. Polymorphism enables programmers to use a different object in place of another provided that object can do the task (implements the same interface).

VCS - Git

  1. all VCS can be categorized into two types: central or distributed.
    • Git is the application that keeps track of everything related to the changes on your project over time
    • GitHub is a host for Git repositories with collaboration features that let you apply and test changes to your code. (Code, Issues, Pull Requests, and Projects.)
    • Git vs. Github Git Is a Version Control Application, GitHub Is a Collaboration Platform. Together, Git and GitHub form the heart of the modern developer’s toolkit.
  2. a few key terms
    • Repositories: A collection of source files used to compile your project. It’s easiest to imagine it as a project folder.
    • Commits: A snapshot of your project as it existed at a specific point in time. You create commits as you work on your project to indicate points when you added and removed discrete units of work.
    • Branch: A series of commits that represent the changes in your project over time. Every repository has a default branch, which contains the production-ready version of your code. Create additional branches when you’re working on new features, fixing bugs, or making other changes to your project. These branches keep your experimental code separate from your tested production code.
    • Merge: The combined history of two or more branches. Most of the time, you’ll merge your feature branch into the default or deployed branch of the repository in order to move the features into production.
    • Tag: A pointer to a specific commit, which provides a persistent reference to an event. Typically, tags are used with semantic versioning to represent points when your application was released.
  3. git command
    • The local and remote repositories only interact when you run one of the four network commands in Git: git clone, git fetch, git pull, and git push.
    • Git uses the config settings for your user name and email address to generate a unique fingerprint for each of the commits you create.
       $ git config --global user.name "First Last"  
       $ git config --global user.email "you@email.com"    
      
    • git branch branchname + git checkout branchname or git checkout -b branchname With Git, checkout moves an important pointer called HEAD, and in this case, moves us to a different branch. HEAD points to the tip of your branch.
    • git log --oneline --graph --decorate displays the same ASCII graph that is displayed using the –graph modifier, but also includes the branch name(s) for the different commits being displayed.
    • By default, the git diff command helps you review the changes between the last commit of your project and the various states of your files
    • use git revert if the commit has been pushed to the remote, you want to change or undo a previous change.
    • use git commit --amend to make a modification to the last commit you made. don’t use git commit –amend if you have already pushed your commits to the remote.
    • git reset rewind the history of our project, but, it alters the commit history, only use reset when you have not pushed your commits to your remote
      • git reset --soft takes the identified commit(s) and places all of the changes in the staging area. This is helpful if you want to take a group of commits and squash them into a single larger commit.
  4. two stage commit

Request and response headers

  1. request message – sent via Uniform Resource Locators (URLs)
  2. url
    • port can be set explicitly,
    • resource path is the local path to the resource on server
  3. web debugging proxies: Fiddler on Windows and Charles Proxy for OSX.
  4. request verb:
    • GET: fetch an existing resource.
      • The URL contains all the necessary information the server needs to locate and return the resource.
    • POST:
      • create a new resource. POST requests usually carry a payload that specifies the data for the new resource.
    • PUT:
      • update an existing resource. The payload may contain the updated data for the resource.
    • DELETE: delete an existing resource. PUT and DELETE are sometimes considered specialized versions of the POST verb, and they may be packaged as POST requests with the payload containing the exact action: create, update or delete.
  5. lesser used verbs that HTTP support:
    • HEAD:
      • similar to GET, but without the message body.
      • It’s used to retrieve the server headers for a particular resource, generally to check if the resource has changed, via timestamps.
    • TRACE:
      • used to retrieve the hops that a request takes to round trip from the server. Each intermediate proxy or gateway would inject its IP or DNS name into the Via header field. This can be used for diagnostic purposes.
    • OPTIONS: used to retrieve the server capabilities. On the client-side, it can be used to modify the request based on what the server can support.

System Design

(In the order for dummies i recommend)

  1. http://www.lecloud.net/tagged/scalability all four parts is very useful
  2. https://www.youtube.com/watch?v=-W9F__D3oY4 class 0 shared some web basics, if you curious.
  3. https://www.hiredintech.com/classrooms/system-design/lesson/55 if you have enough time, go for it
  4. https://github.com/donnemartin/system-design-primer#next-steps you can find a lot more here, pay attention to the graphs, they are great.

    haven’t finished reading, but somebody recommend it

  5. https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/
  6. http://systemdesigns.blogspot.com/2015/11/0.html
  7. https://github.com/checkcheckzz/system-design-interview
  8. https://soulmachine.gitbooks.io/system-design/content/cn/task-scheduler.html?q=

Salesforce Review

|

All content from: http://www.salesforce-interviewquestions.com/p/interview-questions.html, http://www.salesforcetutorial.com/salesforce-interview-questions-answers-part2/, http://www.jitendrazaa.com/blog/tag/interview-questions/

Salesforce Fundamental questions

  1. What is Apex ?
    • It is the in-house technology of salesforce.com which is similar to Java programming with object oriented concepts
    • we can write our own custom logic using Apex.
  2. What is a Visualforce Page ?
    • Visualforce is the new markup language from salesforce, by using which, We can render the standard styles of salesforce.
    • We can still use HTML here in Visualforce. Each visualforce tag always begins with “apex” namespace.
    • All the design part can be accomplished by using Visualforce Markup Language and the business logic can be written in custom controllers associated with the Page.
  3. Will Visual force still supports the merge fields usage like S-control ? Visualforce Pages support embedded merge fields, like the {!$User.FirstName} used in the example.
  4. What are Apex Governor Limits? Governor limits are runtime limits enforced by the Apex runtime engine. Because Apex runs in a shared, multi-tenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that code does not monopolize shared resources. Types of limits that Apex enforces are resources like memory, database resources, number of script statements to avoid infinite loops, and number of records being processed. If code exceeds a limit, the associated governor issues a runtime exception.
  5. Cloud Computing is an approach to provide the following services -
    • SAAS (Software As A Service)
    • PAAS (Platform As A Service)
    • IAAS (Infrastructure As A Service)
  6. Application build block: ||Declarative(simplicity+speed)|Programmatic(control+flexibility)| |Data model | Objects, fields, relationships | Web Service API, metadata API| |Business logic | workflow, validation rules, approval process, assignment rules | Controllers, Apex, Web Service| |User Interface | record type, page layout, applications, tabs | Visualforce Page, Force.com Sites|
  7. formula field: it calculate values using fields within a single record
  8. rollup summary fields. These fields store values aggregated from the child records in the relationship.( it calculates the values from a set of child record)
  9. record types:
    • The report type determines which fields and records are available for use when creating a report.
    • Each report type has a primary object and one or more related objects.
  10. reports: to summarize the information of the object we use reports
  11. Bucket field in Reports is used to group values to the name we specify.
  12. Bucket Field: Used in reports to categories and group report values
  13. Junction Object: A Many-to-Many relationship created with two lookup master-detail relationship

Email to case:

  1. Salesforce can automatically create a case when an email is sent to one of your company’s email addresses, such as support@company.com.
  2. This Email-to-Case functionality auto-populates case fields from the content of each email. For example, an email subject heading becomes a case subject.
  3. Email-to-Case requires downloading and installing the agent. Use Email-to-Case if you have a requirement to keep all email traffic within your firewall, and you want to accept email attachments larger than 25 MB from customers.
  4. On-Demand Email-to-Case uses Apex email services to convert email to cases, without you having to download and install an agent behind your network’s firewall. Use On-Demand Email-to-Case if you are not concerned about keeping email traffic within your firewall and you do not need to accept attachments larger than 25 MB from customers.
  5. Configuration of the Email-to-Case Agent code process consists of the following:
    • Configuring the sfdcconfig.txt file - what username and password does the agent use to connect to Salesforce?
    • Configuring the email2case.txt file - which mailboxes does the agent poll through IMAP?
    • Setting up and test routing addresses - what are the record type, origin, and priority of cases per mailbox being polled?
  6. how to set up On-Demand Email-to-Case:
    • Determine the email routing addresses that your customers can use to submit cases to your support team.
    • Set up assignment rules, escalation rules, and auto-response rules.
    • In Salesforce enable Email-to-Case and configure your email routing addresses.(add a new email routing address, verify the new email routing address, then enable Email-to-Case:)
    • Add email related list to Case page layouts.
    • Configure your email system to forward case submissions to the email services address provided to you by Salesforce.
    • test:
      1. Manually send emails to the routing addresses.
      2. Verify that the emails convert to cases based on their routing address settings.
  7. sample settings/configuration: https://success.salesforce.com/ideaView?id=087300000006tre
  8. Thread Id
    • unique id generated for each case generated via email
    • ensure that the email body and subject both are different, otherwise email-to-case creates an infinite loop of emails related to each case
  9. example: http://focusonforce.com/configuration/salesforce-email-to-case-example/

  10. web-to-case
  11. trigger/workflow
  12. load data

Dashboard and Reports

  1. reports:
    • summary of data that’s stored in the application
    • There can be at most 5 custom summary formula fields are allowed on a single report.
  2. report formats:
    • tabular reports:
      1. tabular reports are the simplest and fastest form reports in salesforce. These are similar to spread sheet.
      2. They consist of ordered set of fields in columns and match record listed in a row.
      3. These reports can not be used to group data or graphs.
    • summary reports:
      1. Summary reports are similar like tabular reports, but also allow users to group rows of data, view sub totals and create charts.
      2. These reports can be used in dashboards.
    • matrix reports:
      1. allow you to group data both by row and column.
      2. can be used in dashboards and graphs.
      3. can not be used as source reports for analytical snapshot
    • joined reports:
      1. Joined reports let you create different views of data from multiple report types.
      2. In joined reports, data is organized in blocks.
      3. Each block acts like a sub-report.
      4. can be used in charts.
  3. Conditional highlighting
    • cannot be used for tabular reports.
    • can be used for Summary and Matrix reports.
    • only applies to the first summary field column in the table.
    • 3 Ranges can be created in case of conditional highlighting.
    • for report: Shows you visual highlights depending on a threshold
  4. dashboard:
    • Dashboard is a container for reports, shows data from source reports as visual components.
    • components includes: Charts, Gauges, Tables, Matrix, Visualforce Pages.
    • A dashboard can hold up to 20 components.
    • A single dashboard can have up to 3 filters.
  5. dynamic dashboard:
    • dynamic dashboards are dashboards show data according to users own security settings.
    • A sales manager would like to view a dashboard from the perspective of different users and switch between users without editing the dashboard, how would an administrator enable this?
      • Create the dashboard as a dynamic dashboard
      • Grant the sales manager the “View my Teams Dashboard” permission
  6. It is possible for a user to see different set of data in report and in a dashboard based on the same report.
  7. All dashboard viewers see data based on the security settings of the Running User regardless of their own personal security settings.
  8. Running User concept in Dashboard allows users to view Data which normally they cannot view.
  9. Dashboard snapshot on the home page displays First row of any available dashboards.

Standard controller & custom controller:

  1. Standard controller: by using standard controller you need not have to write apex code. Standard controller can be accessed on one object and referenced by visualforce page. It also provides some save, cancel, clone for that object. Standard controller provides the same functionality what standard pages provide
  2. custom controller: A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.
  3. A controller extension
    • is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:
    • You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
    • You want to add new actions.
    • You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.

Export

  1. How to schedule export backup of salesforce data
    • Salesforce allows you to obtain a copy of all your data using the data export feature.
    • You can generate backup files manually once every six days or schedule them to generate automatically at weekly or monthly intervals.
    • The backup file will come to you in the form a zip file that contains all of your organization’s data in a set of CSV (comma-separated values) files.
    • Step by Step Instruction:
      • Click Setup >Data Management > Data Export > Schedule Export.
      • Select the desired encoding for your export file. Leaving the default is fine.
      • Check the Include in export checkbox if you want to include attachments in the export (optional)
      • Leave the default Replace carriage returns with spaces if you want your export files to have spaces instead of carriage returns.
      • Select Weekly as the the frequency for the exports.
      • Choose start and end dates. Set the end date to sometime in the distant future such as 20 years from the begin date.
      • Set the time of day for your scheduled export. The export is put in a job queue and the exact time of the export will depend on the amount of activity in the queue.
      • You can select the types of data to include in your export. It is best to include all data in your export file. This will make sure all your organizations data is exported.
      • Click Save.
    • tips:
      • Formula, roll-up summary fields and articles are not included in exports.
      • Scheduled backup exports of your data is limited to weekly exports.
      • You have 48 hours from the time you are notifiedthe backup is available to download the backup file.
      • The export notification email is only sent to the email address on file for the user who created the scheduled export. The email notification for backups goes to the email address in Salesforce of the person logged in who schedules the backup

Deployment and test

  1. Difference between Sandbox and developer edition in Salesforce
    • Sandbox:
      • The salesforce.com Sandbox environment is an exact copy of your salesforce.com instance.
      • You can copy your live instance to a sandbox environment where you can test any changes, implementations, AppExchange apps or updates.
      • You have to perform manually from sandbox to developer edition.
      • Workflow rules or automations will work in the sandbox as well.
      • Included in Unlimited Edition, but hefty for Enterprise, Professional or Group Edition.
    • Developer Edition
      • Developer Edition was an edition created for development of integrations and apps, specifically for the AppExchange.
      • It is also a great tool for testing/training in salesforce.com.
      • Free
      • It is a standard Enterprise Edition with very limited storage space.
      • You cannot copy your configuration or data onto the Developer Edition, but you can customize it to match your instance’s look and feel. Once it is customized, you can use it for training, testing or anything else you want.
  2. How to migrate data from developer sandbox to production? You have to use full sandbox to deploy the data from sandbox to production. You have to request salesforce for this or else you can use data loader to export the data from one org and import the same on another org.

Web Service

  1. How external app access salesforce?
    • Simple Object Access Protocol (SOAP) and Representational State Transfer (REST)
      • REST(architecture)
        • apex rest api: when we want to expose apex classes and methods we use this so that external app can access you code through rest architecture. it supports both oauth and session id for authorization.
        • rest is client based protocol, do CRUD operations, can work with any database, any data structure. SOAP message, define logic in soap message. SF support both.
      • SOAP
        • soap api: SOAP is a standards-based Web services access protocol that has been around for a while and enjoys all of the benefits of long-term use. Originally developed by Microsoft
        • sf-soap: soap API. Salesforce provides a WSDL (Web Service Description Language) files. They are called “Enterprise WSDL” and “Partner WSDL”. (https://help.salesforce.com/articleView?id=000004760&language=en_US&type=1) Enterprise, can not used for different users because of different data structure; partner wsdl, use any object, use general calls, more flexible, maybe need type cast, eg: phone
      • soap Vs. rest: rest faster than soap, rest can do all translate. rest and soap are protocol, soap only xml, rest can do both(xml,json),rest is much easier to develop, soap is secure with structured contract defined,
    • access sf:
      • login login.sf.com, a server called “login” dealing with login service
      • server give a token back,
      • session id
    • when sf want to access other systems, the API we should choose depends on what protocol that system uses. sf have tool which can convert .wsdl/.rest file(in that system) into neighbor object.
    • google:
      • both SOAP and REST share similarities over the HTTP protocol, SOAP is a more rigid set of messaging patterns than REST. The rules in SOAP are important because without these rules, you can’t achieve any level of standardization. REST as an architecture style does not require processing and is naturally more flexible. Both SOAP and REST rely on well-established rules that everyone has agreed to abide by in the interest of exchanging information.
  2. API:
    • bulk api : it is specialized restful api, it is used to loading and querying lots of data lots of data in the scense 50000 above.

    • streaming api: it is used to setup notifications that triggers when the changes are made to the data

    • metadata api: it is used to retrieve, deploy, create,update or delete customizations from your org, the most common use is to migrate from sandbox or testing org to production.

    • tooling api: when we want integrate salesforce metadata with other systems.rest and soap are both supported we use tooling api to manage and deploy working copies of apex classes,triggers,visualforce,and components.

    • api request times for 20 seconds dev org-5 trail-5 pro-25 sand-25

Security – Who sees what:

  1. OWD -> role hierarchy -> sharing rules -> manual sharing.
  2. org-wide defaults (also known as sharing settings)
    • OWD is the default access level on records for any object in sales force.
    • org-wide defaults determine what access and permissions users have to records they do not own.
    • how org-wide defaults work in conjunction with profile permissions? The permissions determine the baseline level of access a user has to all record. Org-wide defaults can then further restrict these permissions on records a user does not own.
  3. Profile determine the objects a user can access, and the permissions a user has on an object record and which tab, app are visible.
  4. Permission Sets - To improve the permissions for the users over profiles we should go for Permission Sets. To give additional permissions to few users who belongs to different profiles over Apps, Tabs, sObjects and fields.
  5. A users baseline permissions on each object are determined by the profile. If you are using permission sets, these also set the baseline permissions in conjunction with the profile
  6. By default after creating custom object OWD access level is Public Read/Write.
  7. role hierarchy - a way to extend access to record, when org-wide default have been set to anything more restrictive than public read/write.
    – The role hierarchy enables users above another user in the hierarchy to have the same level of access to records owned by or shared with users below.
  8. implement sharing rules: we can implement sharing rules to open record access up to users when the org-wide defaults have been set to less than public read/write
  9. Sharing Rules – used by administrators to automatically grant users within a given group or role access to records owned by a specific group of users.
  10. Manual Sharing– Manual managed sharing allows the record owner or any user with Full Access to a record to share the record with a user or group of users.
  11. Profile vs. Permission sets:
    • profiles are like global….and permission sets are local.
    • While users have only one profile, they can have many permission sets.
    • For example, if you have one profile assigned to 20 different users.
Now Suppose you want give some extra permission to one of user. You have two options here.
a) To change Profile permissions : By this way those extra permissions will received by every user who is having that profile
b) Second way is to create a permission set having those extra permission. You need to assign this permission set to particular user by navigating to User detail page. In this way, you dont have to worry about other users, as only specific user is getting those extra permissions.
  12. what are sharing rules in salesforce?
    • Sharing rules are used by administrators to automatically grant users within a given group or role access to records owned by a specific group of users. Sharing rules cannot be added to a package and cannot be used to support sharing logic for apps installed from Force.com AppExchange.
    • Sharing rules can be based on record ownership or other criteria. You can’t use Apex to create criteria-based sharing rules. Also, criteria-based sharing cannot be tested using Apex.
    • All implicit sharing added by Force.com managed sharing cannot be altered directly using the Salesforce user interface, SOAP API, or Apex.
    • For example, use sharing rules to extend sharing access to users in public groups, roles, or territories. Sharing rules can never be stricter than your organization-wide default settings. They simply allow greater access for particular users.
    • you can create sharing rules based on record owner or field values in the record. This enables you to make automatic exceptions to your organization-wide sharing settings for defined sets of users.
  13. Organization access:
    • IP Ranges(company level): Users outside the range are sent an activation code
    • IP Ranges(profile level): Users outside this range are denied access
    • Login Hours(profile level): specified hours are enforced In Salesforce, permissions and access settings specify
  14. Object access: Profile - users baseline permission
    • Profile determine the objects a user can access, and the permissions a user has on an object record and which tab, app are visible.
    • standard profiles are provided by salesforce, these profiles may not be edited, but can be cloned and then edited to create custom profiles.
    • clone then edit, app/system
    • profile deals with credential permissions on tabs, objects, fields, record types etc and we can map only one profile to one uses and with out profile we cannot create user.
    • (Profile give users access to objs, tabs, fields, record types and many other functions.)
    • a profile provides access for general functions that a type of user performs.
  15. Permissions sets:
    • To improve the permissions for the users over profiles we should go for Permission Sets. To give additional permissions to few users who belongs to different profiles over Apps, Tabs, sObjects and fields.
    • can extend a user’s access and permission
    • some users need access to additional objs and settings and you don’t want to grant that access to everyone with the profile
    • assign a permission set to the users who need it.
  16. Profile vs. Permission sets:
    • While users have only one profile, they can have many permission sets.
  17. org-wide defaults (also known as sharing settings)
    • org-wide defaults determine what access and permissions users have to records they do not own.
    • how org-wide defaults work in conjunction with profile permissions? The permissions determine the baseline level of access a user has to all record. Org-wide defaults can then further restrict these permissions on records a user does not own.
  18. role hierarchy: a way to extend access to record, when org-wide default have been set to anything more restrictive than public read/write
  19. implement sharing rules: we can implement sharing rules to open record access up to users when the org-wide defaults have been set to less than public public read/write
Field Level Security
  1. restrict a profiles view to a certain field
  2. Field Level Security or Page Layout can not be used to make a field required
  3. Formulas ignore Field Level Security settings
summary:
  1. record level permission set. 4 record access level: org-wide default: user can see other users’ record when other users’ record are set as org-wide default
  2. role: sharing: horizontal sharing with different department manually sharing: sharing to anyone you want access greater.
  3. profile/permission set: object/field level profile-baseline /permission set-additional

Workflow, trigger, process builder

  1. trigger: many objects, before and after
    • Trigger will perform actions before / after the record creation/update, it not only work on records, but also on diff places of declarative functionality of force.com platform
    • such as before object records are inserted into the database, or after records have been deleted.
  2. workflow:
    • Workflow enables you to set up workflow rules.
    • A workflow rule identifies what kinds of record changes or additions trigger specified workflow actions, such as sending email alerts and updating record fields.
    • Workflow rules and actions are associated with a specific object (and can cross objects only to update fields on a related master record).
    • Workflow lets you automate standard internal procedures and processes to save time across your org.
    • A workflow rule is the main container for a set of workflow instructions. These instructions can always be summed up in an if/then statement.
    • Workflow will perform operations after record creation/update,
    • only on one object
  3. visual workflow: Visual Workflow enables you to create flows, which are triggered by users rather than events. Unlike Workflow, which always executes rules and actions behind the scenes, Visual Workflow offers screens for displaying and collecting information from the user running the flow.
  4. workflow(outbound) vs process builder:
    • In short, you can do everything you can do with workflows using process builder as well, except for sending outbound messages with point&click.
    • With process builder, you can also update all child records starting from the parent record, which is not possible with workflows (only vice versa is possible using cross object field updates).
    • I’ve heard rumors that process builder will replace workflows in the future, which seems a logical step to take for sfdc.
  5. Where to use trigger and where to use work flow?
    1. Workflow is point and click which doesn’t need any coding. When you want to take action (email, task, field update or outbound message) for the same object or from Child to parent object, you can use Workflow rules.
    2. Trigger: It’s a programmatic approach and event driven (insert, update, merge, delete). You can call it as advance version of Workflow.
    3. Trigger works across all the objects.
    4. You can create a new record through trigger which is not possible through workflow
    5. Workflows work only after some actions. Trigger works before and after some actions.
  6. what are the differnt kinds of workflow actions:
    • new field update
    • new email alert
    • new task
    • new outbound message
  7. types of email templates:
    • text
    • HTML
    • custom template
    • visualforce
  8. A customer service manager would like to automatically assign cases to the most appropriate agent to handle the request

test & size

Roles:
  1. DEV
    • back-end
    • front-end UI
  2. UX
  3. QA
    • manual testing
    • automation testing
  4. BA
  5. Architect
  6. Scrum Master - Team Leads
  7. Project Manager
  8. DBA
  9. Delivery Manager
test(order)
  • unit testing
  • system testing
  • smoke
  • regression
  • load/performance
  • UAT user acceptance testing, client QA worked on this part
  • production
Terms
  • MOM minutes of meeting
  • RCA root cause analysis
  • IA impact analysis

Salesforce 4 -- Apex Basics

|

Notes from: https://trailhead.salesforce.com/trails All content from: https://trailhead.salesforce.com/trails

5. Developer Beginner ( Get the platform developer1 certificate, yay!)

1. Formula Fields
  • Let’s take a single field from an Account and show it on a Contact using what’s called a cross-object formula.
  • Say, for example, you have a hundred opportunities listed in a report, but only a handful of users own all these opportunities. How do you find the number of distinct users? This task sounds difficult, but it’s one of the easiest formulas you can write. It’s called the Power of One.
  • You can use the Power of One on any object. For example, if you had a report with 10 accounts, each with three opportunities, your Opportunities report returns 30 records. Adding the Power of One formula field to Account allows you to see the number of distinct accounts represented in the records.
  • VALIDATION:(formula = true, not valid)
    1. Validates that the Account Number is numeric if not blank. Error Message: Account Number is not numeric.
           AND(
       NOT(ISBLANK(AccountNumber)),
       NOT(ISNUMBER(AccountNumber))
        )
      
    2. Validates that a custom date field contains a date within the current year. YEAR( My_Date__c ) <> YEAR ( TODAY() )
    3. Validates that the range between two custom fields, Salary Min and Salary Max, is no greater than $20,000. Error Message: Salary range must be within $20,000. Adjust the Salary Max or Salary Min values. (Salary_Max__c - Salary_Min__c) > 20000
2. Data Security
  • you can provide just the right level of data access to thousands of users without having to specify permissions for each user individually.
  • Although you can configure the security and sharing model entirely using the user interface, it is implemented at the API level. That means any permissions you specify for objects, records, and fields apply even if you query or update the data via API calls.
  • Organization: At the highest level, you can secure access to your organization by maintaining a list of authorized users, setting password policies, and limiting login access to certain hours and certain locations.
  • Objects: By setting permissions on a particular type of object, you can prevent a group of users(by profile) from creating, viewing, editing, or deleting any records of that object.
    • For example, you can use object permissions to ensure that interviewers can view positions and job applications but not edit or delete them.
    • There are two ways of setting object permissions. You can use profiles or permission sets.
  • Fields: you can use field-level security to restrict access to certain fields, even for objects a user has access to.
    • For example, you can make the salary field in a position object invisible to interviewers but visible to hiring managers and recruiters.
  • Records: To control data with greater precision, you can allow particular users to view an object, but then restrict the individual object records they’re allowed to see.
    • For example, record-level access allows an interviewer to see and edit her own reviews, without exposing the reviews of other interviewers. You can manage record-level access in these four ways.
    • record level access: Organization-wide defaults specify the default level of access users have to each others’ records.
      • You use organization-wide sharing settings to lock down your data to the most restrictive level, and then use the other record-level security and sharing tools to selectively give access to other users.
    • record level access: Role Hierarchies open up access to those higher in the hierarchy so they inherit access to all records owned by suers below them in the hierarchy.
      • each role in the hierarchy should represent a level of data access that a user or group of users needs.
    • record level access: Sharing rules enable you to make automatic exceptions to organization-wide defaults for particular groups of users, to give them access to records they don’t own or can’t normally see.
      • Sharing rules, like role hierarchies, are only used to give additional users access to records—they can’t be stricter than your organization-wide default settings.
    • record level access: Manual sharing allows owners of particular records to share them with other users.
  • When implementing security and sharing rules for your organization, make a table of the various types of users in your organization. In the table, specify the level of access to data that each type of user needs for each object and for fields and records within the object. You can then refer to this table as you set up your security model.
  • Auditing features include: Record Modification Fields; Login History;Field History Tracking; Setup Audit Trail
  • The System Administrator profile also includes two special permissions: View All Data,Modify All Data。
  • A permission set is a collection of settings and permissions that give users access to various tools and functions. permission sets extend users’ functional access without changing their profiles.
    • For example, to give users access to a custom object, create a permission set, enable the required permissions for the object, and assign the permission set to the users.
    • two common scenarios in which permission sets are useful.To grant access to custom objects or entire apps. To grant permissions—temporarily or long term—to specific fields.
3. Process Automation
  • Salesforce provides multiple tools to automate your org’s repetitive business processes: Lightning Process Builder, Visual Workflow, Workflow, and Approvals.
  • Process and workflow: In fact, a single process can do what it would normally take multiple workflow rules to do. The only thing you can do with workflow that you can’t do with processes is send outbound messages without code.
  • If the process is too complicated for the Process Builder or requires more advanced functionality, create a flow by using the Cloud Flow Designer.
  • If you need to build a wizard to collect information, Visual Workflow is the tool for you. Create a flow that displays information to and requests information from a user. Then take the information that they enter and perform actions in Salesforce with it.
  • a useful table(https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/business_process_automation/units/process_whichtool)
  • Do I need to get information from a user? -if yes, use visual workflow, if no, use process builder
  • Whenever possible, automate your if/then statements with Process Builder instead of workflow rules.
  • When a user first requests approval for a new position, initial submission actions occur. The default initial submission action locks the record. This action ensures that other users (except for approvers and administrators) can’t change the record while the record is pending approval.
  • tasks:
    • In some instances, a case must automatically escalate. Create a workflow rule that will set the escalated flag and send a task to the case owner if a case is not closed and its priority is set to High.
    • You’ve been given a requirement to keep Contact addresses in sync with the Account they belong to. Use Process Builder to create a new process that updates all child Contact addresses when the address of the Account record is updated.
4. Apex Basics:
  1. Apex supports:
    • classes, interfaces, properties, collections
    • Object array notation
    • Expressions, variables, and constants
    • Conditional statements (if-then-else) and control flow statements (for loops and while loops)
    • Cloud development as Apex is stored, compiled, and executed in the cloud.
    • Triggers
    • soql
    • Transactions and rollbacks
    • The global access modifier
  2. Data type:
    • primitives: Integer, Double, Long, Date, Datetime, String, ID, Boolean, among others
    • sObject
    • collection: list, set, map
    • A typed list of values, also known as an enum
    • User-defined Apex classes
    • System-supplied Apex classes
  3. List
    • declaration:List<String> colors = new List<String>(); or String[] colors = new List<String>();
    • Get elements from a list
        String color1 = moreColors.get(0);
        String color2 = moreColors[0];
        System.assertEquals(color1, color2);
      
    • List elements can be read by specifying an index between square brackets, just like with array elements. Also, you can use the get() method to read a list element.
  4. sObject
    • doc: https://developer.salesforce.com/docs/atlas.en-us.206.0.object_reference.meta/object_reference/sforce_api_objects_concepts.htm
    • add fields: Account acct = new Account(Name='Acme');
  5. DML(Data Manipulation Language)
    • insert/update/upsert/delete/undelete/merge
    • The upsert DML operation creates new records and updates sObject records within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified.
    • The merge statement merges up to three records of the same sObject type into one of the records, deleting the others, and re-parenting any related records.
  6. You can perform DML operations either on a single sObject, or in bulk on a list of sObjects.
  7. BULK - Performing a DML operation on a list of sObjects counts as one DML statement for all sObjects in the list, as opposed to one statement for each sObject.
  8. upsert upsert sObjectList Account.Fields.MyExternalId; Upsert uses the sObject record’s primary key (the ID), an idLookup field, or an external ID field to determine whether it should create a new record or update an existing one:
  9. upsert example
     Contact jane = new Contact(FirstName='Jane',
                             LastName='Smith',
                             Email='jane.smith@example.com',
                             Description='Contact of the day');
     insert jane;
    
     // 1. Upsert using an idLookup field
     // Create a second sObject variable.
     // This variable doesn’t have any ID set.
     Contact jane2 = new Contact(FirstName='Jane',
                             LastName='Smith',  
                             Email='jane.smith@example.com',
                             Description='Prefers to be contacted by email.');
     // Upsert the contact by using the idLookup field for matching.
     upsert jane2 Contact.fields.Email;
    
     // Verify that the contact has been updated
     System.assertEquals('Prefers to be contacted by email.',
                     [SELECT Description FROM Contact WHERE Id=:jane.Id].Description);
    
  10. Deleted records aren’t deleted permanently from Force.com, but they’re placed in the Recycle Bin for 15 days from where they can be restored.
  11. DML Statement Exceptions DmlException e; e.getMessage();
  12. These Database methods are static and are called on the class name. eg: Database.insert(recordList, false);
  13. Database methods have an optional allOrNone parameter that allows you to specify whether the operation should partially succeed.
    • When this parameter is set to false, if errors occur on a partial set of records, the successful records will be committed and errors will be returned for the failed records. Database.insert(recordList, false);
      • Also, no exceptions are thrown with the partial success option.
      • Database.SaveResult[] results = Database.insert(recordList, false); //The Database methods return result objects containing success or failure information for each record. For example, insert and update operations each return an array of Database.SaveResult objects.
    • By default, the allOrNone parameter is true, which means that the Database method behaves like its DML statement counterpart and will throw an exception if a failure is encountered.
    • In addition to these methods, the Database class contains methods that aren’t provided as DML statements. For example, methods used for transaction control and rollback, for emptying the Recycle Bin, and methods related to SOQL queries.
  14. when use which one?
    • Use DML statements if you want any error that occurs during bulk DML processing to be thrown as an Apex exception that immediately interrupts control flow (by using try. . .catch blocks).
    • Use Database class methods if you want to allow partial success of a bulk DML operation—if a record fails, the remainder of the DML operation can still succeed.
  15. SOQL:Account[] accts = [SELECT Name,Phone FROM Account]; // wrap the SOQL statement within square brackets and assign the return value to an array of sObjects.
  16. perform fuzzy matches by using the LIKE operator. For example, you can retrieve all accounts whose names start with SFDC by using this condition: WHERE Name LIKE ‘SFDC%’. The % wildcard character matches any or no character. The _ character in contrast can be used to match just one character.
  17. To get child records related to a parent record, add an inner query for the child records.
  18. Inner Query: //To get child records related to a parent record, add an inner query for the child records.
    Account[] acctsWithContacts = [SELECT Name, (SELECT FirstName,LastName FROM Contacts)
                                FROM Account 
                                WHERE Name = 'SFDC Computing'];
    // Get child records
    Contact[] cts = acctsWithContacts[0].Contacts;
    System.debug('Name of first associated contact: ' 
                + cts[0].FirstName + ', ' + cts[0].LastName);
    
  19. You can traverse a relationship from a child object (contact) to a field on its parent (Account.Name) by using dot notation.
    Contact[] cts = [SELECT Account.Name FROM Contact 
                    WHERE FirstName = 'Carol' AND LastName='Ruiz'];
    Contact carol = cts[0];
    String acctName = carol.Account.Name;
    System.debug('Carol\'s account name is ' + acctName);
    
  20. Querying Record in Batches By Using SOQL For Loops
    insert new Account[]{new Account(Name = 'for loop 1'), 
                     new Account(Name = 'for loop 2'), 
                     new Account(Name = 'for loop 3')};
    
    // The sObject list format executes the for loop once per returned batch
    // of records
    Integer i=0;
    Integer j=0;
    for (Account[] tmp : [SELECT Id FROM Account WHERE Name LIKE 'for loop _']) {
        j = tmp.size();
        i++;
    }
    System.assertEquals(3, j); // The list should have contained the three accounts
    System.assertEquals(1, i); // Since a single batch can hold up to 200 records and, only three records should have been returned, the loop should have executed only once
    
  21. Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records. SOSL is similar to Apache Lucene.
  22. List<List<SObject>> searchList = [FIND 'SFDC' IN ALL FIELDS RETURNING Account(Name), Contact(FirstName,LastName)]; //When SOSL is embedded in Apex, it is referred to as inline SOSL, searches for accounts and contacts that have any fields with the word ‘SFDC’.
  23. SOQL Vs. SOSL
    • Like SOQL, SOSL allows you to search your organization’s records for specific information. Unlike SOQL, which can only query one standard or custom object at a time, a single SOSL query can search all objects.
  24. syntax of SOSL: FIND 'SearchQuery' [IN SearchGroup] [RETURNING ObjectsAndFields]
    • SearchQuery is the text to search for (a single word or a phrase). Search terms can be grouped with logical operators (AND, OR) and parentheses.
    • search terms can include wildcard characters (*, ?). The * wildcard matches zero or more characters at the middle or end of the search term.
    • The ? wildcard matches only one character at the middle or end of the search term.
    • SearchGroup can take one of the following values: ALL FIELDS, NAME FIELDS, EMAIL FIELDS, PHONE FIELDS, SIDEBAR FIELDS
    • ObjectsAndFields is optional. It is the information to return in the search result—a list of one or more sObjects and, within each sObject, list of one or more fields, with optional values to filter against. If not specified, the search results contain the IDs of all objects found.
  25. example of SOSL : 1. ...RETURNING Account(Name, Industry WHERE Industry='Apparel') //filter
    1. List<List<sObject>> searchList = [FIND 'Wingo OR SFDC' IN ALL FIELDS 
                 RETURNING Account(Name),Contact(FirstName,LastName,Department)];
      Account[] searchAccounts = (Account[])searchList[0];
      Contact[] searchContacts = (Contact[])searchList[1];
      

Security Specialist

  1. Here are the three protocols that Salesforce and other identity vendors follow to implement identity solutions.
    • SAML(SAML is an XML-based protocol)
    • OAuth 2.0
    • OpenID Connect

Sens:

  1. Operating on a list of sObjects is a more efficient way for processing records.
  2. All those statements, except a couple, are familiar database operations.
  3. can be quite handy.
  4. using a specified field to determine the presence of existing objects, or the ID field if no field is specified.
  5. In addition to persisting the ID value in the database, the ID value is also autopopulated on the sObject variable that you used as an argument in the DML call.
  6. The fields are specified after the SELECT keyword in a comma-delimited list.

Salesforce 3 -- CRM Essential

|

Notes from: https://trailhead.salesforce.com/trails All content from: https://trailhead.salesforce.com/trails

4. CRM Essential

  1. Accounts are companies that you’re doing business with, and contacts are the people who work for them.
  2. If you’re doing business with a single person, like a solo contractor or an individual consumer, you use a special account type called a Person Account.
  3. Understanding how to use accounts and contacts is key to getting the most out of Salesforce CRM.
  4. Account View: When you open the account record, you see the information collected on the company as a list of records related to it, such people who work there, deals in the works, service requests, uploaded documents, and more.
  5. The Social Accounts, Contacts, and Leads feature adds social network information from Twitter, Facebook, YouTube, and Klout to your records. To use it, you must have an account on each social network that you’re using, and you have to link the account or contact record to a user profile on each social network.
  6. Managing Accounts and Contacts
    1. Establish naming conventions for accounts
    2. Don’t allow orphan contacts. Always associate contacts with an account.
    3. Audit your accounts and contacts. Use exception reporting in Salesforce to find accounts and contacts without activities in the last 30, 60, or 90 days. Or create an “inactive” checkbox field on your account and contact objects, and use mass update to denote inactive accounts. Set up an automated process to mark accounts and contacts inactive for you, based on criteria you specify.
    4. Handle inactive accounts and contacts. For example:
      • Organize an outreach campaign to re-engage with them
      • Exclude them from list views, reports, automated processes, campaigns, and more so you can focus marketing, sales, and service efforts on active customers .
    5. Maintain active ownership
  7. Three Key Account and Contact Relationships
    • Contacts to Multiple Accounts lets you relate a contact to more than one account so you can track the relationships between people and the companies they work with.
      • add roles to direct and indirect contacts so you know who’s your best bet.
      • Account Hierarchy lets you see what companies ABC Genius is affiliated with.
      • Account Teams tells you which sales reps are working on the ABC Genius deal so you can better coordinate with your internal team
  8. how to establish accounts for businesses with multiple locations. two basic choices:
    • Global Enterprise Account
    • Location-Specific Accounts(recommended)
  9. Sales Process and using opportunities
    • Opportunities are deals in progress, you can create opportunities for existing accounts or by converting a qualified lead
    • an opportunity moves through a series of stages linked to type of tasks being performed, who’s got the ball, and how likely it is that the sale will be made
    • stages you usually go through might look like this: prospecting –> developing –> negotiation/review –> closed won/closed lost
    • Each stage is associated with a probability that the deal will be completed successfully. The default probability is set by the administrator.
    • Each stage must be assigned a probability. Probabilities are used when creating forecasts, which are not covered in this course.
    • Create an Opportunity Record Type. The record type is how you link a particular page layout and sales process to a type of product. Record types determine which types of sales opportunities pass through which sales process.
    • Opportunity Teams are a bit like Account Teams. Both allow you to relate particular people at your company to accounts or opportunities. But where Account Team members can be expected to form a long-term relationship with the customer, an Opportunity Team is a temporary group composed of people who can help you close the deal.
  10. Converting and assigning leads
    • Leads are people and companies that you’ve identified as potential customers.
    • big advantages to using leads like knowing what’s in your pipeline and focusing your energy on the right deals. You can better track, report on, and target marketing campaigns to prospective customers. Leads may help you concentrate on the potential deals most likely to close. They also help executives maintain visibility and help on key deals
    • how to catch leads: Leads created from a web form or other automatic process. add leads by importing a file into Salesforce or through an automatic process, such as a Web-to-Lead form that collects leads from your business website.
    • assignment rule Before setting up lead assignment rules for your company, you should carefully review your existing business process to determine how leads should be assigned. After leads have been assigned according to your process, be sure to include a catch-all assignment rule to catch any leads who don’t somehow qualify for any other rules.
    • convert
      1. When you qualify a lead, you can convert the lead record into an opportunity. Qualifying a lead indicates that you believe that the lead has a use for and interest in your products, and that a sale to the lead is a definite possibility
      2. When you convert a lead, Salesforce uses the information stored in the lead record to create a business account, a contact, and an opportunity.
      3. If your organization has person accounts enabled and the lead record didn’t include a company name, the lead is converted into a person account and an opportunity.
  11. Data Quality
    • how to assess the quality of your company’s data.
      • The first step in assessing data quality is to figure out how your company uses customer data to support its business objectives. Sounds like a good start. You meet with managers and reps across Gelato and ask them: What are your business objectives? What customer data do you need to support those objectives? How are you using that customer data? Where is your customer data stored?
  12. SKIP CPQ