Sunday 21 September 2014

Change background color in visualforce page.

Now we create a color picker in visualforce page.Which is help to change the background color of visualforce page.

<apex:page showHeader="false">

  <script>
      function changeColor(inputID){
              var inputValue = document.getElementById(inputID).value;
              return ( document.body.style.backgroundColor =[document.getElementById(inputID).value]);
      }
      function focus(){
              j$("[id$=loading-curtain-div]").css("background-color", "blue").css("opacity", 0.35);
      }
  </script>

      <style>
             .ash_gray{ background-color:#666362; color:white;  }
      </style>

     <apex:sectionHeader title="Color codes" subtitle="Pick Color">
         </apex:sectionHeader>      
       
           <apex:pageBlock >
               <apex:form id="myform" >
                  <div id="loading-curtain-div"/>
                     <apex:pageBlockSection columns="2" id="mypageblockSection">
                         <apex:outputText value="Ash Gray:" style="font-size:15px;"/>
                              <apex:commandButton id="cmd1" onclick="changeColor('{!$Component.cmd1}')" onmouseout="focus();"  reRender="myform" value="#666362" style="background:#666362;width:80px" />
                         <apex:outputText value="Slate Bliue:" style="font-size:15px;"/>
                              <apex:commandButton id="cmd2" onclick="changeColor('{!$Component.cmd2}')" reRender="myform" value="#737CA1" style="background:#737CA1;width:80px" />
                         <apex:outputText value="Blue Jay:" style="font-size:15px;"/>
                              <apex:commandButton id="cmd3" onclick="changeColor('{!$Component.cmd3}')" reRender="myform" value="#2B547E" style="background:#2B547E;width:80px"/>
                         <apex:outputText value="Blue Hosta:" style="font-size:15px"/>
                              <apex:commandButton id="cmd4" onclick="changeColor('{!$Component.cmd4}')" reRender="myform" value="#77BFC7" style="background:#77BFC7;width:80px"/>      
                         <apex:outputText value="Light Sea Green:" style="font-size:15px "/>
                              <apex:commandButton id="cmd5" onclick="changeColor('{!$Component.cmd5}')" reRender="myform" value="#3EA99F" style="background:#3EA99F; width:80px"/>
                         <apex:outputText value="Dark Turquoise:" style="font-size:15px"/>
                              <apex:commandButton id="cmd6" onclick="changeColor('{!$Component.cmd6}')" reRender="myform" value="#3B9C9C" style="background:#3B9C9C;width:80px"/>
                         <apex:outputText value="Sea Turtle Green:" style="font-size:15px"/>
                              <apex:commandButton id="cmd7" onclick="changeColor('{!$Component.cmd7}')" reRender="myform" value="#438D80" style="background:#438D80;width:80px"/>
                         <apex:outputText value="Coffee:" style="font-size:15px;"/>
                              <apex:commandButton id="cmd8" onclick="changeColor('{!$Component.cmd8}')" reRender="myform" value="#827B60" style="background:#827B60;width:80px"/>
                         <apex:outputText value="Plum Purple:" style="font-size:15px"/>
                              <apex:commandButton id="cmd9" onclick="changeColor('{!$Component.cmd9}')" reRender="myform" value="#6F4E37" style="background:#6F4E37;width:80px"/>
                         <apex:outputText value="Plum Velvet:" style="font-size:15px"/>
                              <apex:commandButton id="cmd10" onclick="changeColor('{!$Component.cmd10}')" reRender="myform" value="#7D0552" style="background:#7D0552;width:80px"/>
                         <apex:outputText value="Army Brown:" style="font-size:15px"/>
                               <apex:commandButton id="cmd11" onclick="changeColor('{!$Component.cmd11}')" reRender="myform" value="#5E5A80" style="background:#5E5A80;width:80px"/>
                         <apex:outputText value="Plum Purple:" style="font-size:15px"/>
                               <apex:commandButton id="cmd12" onclick="changeColor('{!$Component.cmd12}')" reRender="myform" value="#583759" style="background:#583759;width:80px"/>
             </apex:pageBlockSection>
         </apex:form>
    </apex:pageBlock>
 
</apex:page>

How to Print The Current Visualforec Page with the help of JavaScript.

There is a method name is Window.print() in JavaScript.
The print() method opens the Print Dialog Box, which lets the user to select preferred printing options.

So, In visualforce page we use this method in commandButton's onclick attribute.


<apex:commandButton onclick="window.print()" value="Print"/>


Simple and after clicking on Print button the print method prints the contents of the current Visualforce page.

Custom Exception in Salesforce

public class CustomExceptionClass {
   
// define custom exception with extend the built-in Exception class
// And make sure your class name ends with the word Exception,
// else you get Compile Error: Invalid type

class MyException extends Exception{

    //Override the getMessage method of Exception class to show you custom Error
  override public String getMessage(){
  return 'The Show is HouseFull, No more Tickets are available';
  }

}

// declare custom exception variable
        MyException myExceptionVar = null;
   
 //Constractor of OuterClass
        public CustomExceptionClass(){
            // create object of Custom Exception class
            myExceptionVar = new MyException();

        }

        Integer TotalTickets = 5; // define some custom limit for error condition
 // Define some person name who booked ticket
        List<String> PersonName = new String[]{'Harry','Ron','Hermione'};  

        public Boolean addPerson(String newPersonName){ // Add another person
            Boolean TicketBooked = false;
         
            //use try Catch for Exception
            try{  
                    //Check the List
            if(PersonName.size() >= TotalTickets) // If return True then throw Exception
           throw myExceptionVar;
                    // Throw Exception it'll show the error which we written in getMessage
               
                else //Else Add the Person name
                PersonName.add(newPersonName);

                TicketBooked = true;

            }
            //Catch block
            catch(Exception e){
                TicketBooked = false;
                System.debug('we are in catch block');
                System.debug(e.getMessage());
            }
            finally{
             
                if(TicketBooked)
                System.debug('Ticket Booked successfully');
                else
                System.debug('Booking failed');
               }
               return TicketBooked ;

        }
}


// Execute Following

CustomExceptionClass a = new CustomExceptionClass();
//Current list size is 3  ('Harry','Ron','Hermione') and limit is 5 so we can add two more

a.addPerson('Viru'); // Ticket Booked Successfully
a.addPerson('Emma'); // Ticket booked Successfully

//current list size id 5  and limit is 5 so we are not good
a.addPerson('Draco');  //Booking failed 

Tuesday 16 September 2014

BODMAS Rule

B → Brackets first (parentheses)

→ Of (orders i.e. Powers and Square Roots, Cube Roots, etc.)

DM  Division and Multiplication (start from left to right)

AS → Addition and Subtraction (start from left to right)

Note:

(i) Start Divide/Multiply from left side to right side since they perform equally.

(ii) Start Add/Subtract from left side to right side since they perform equally.

Steps to simplify the order of operation using BODMAS rule:

First part of an equation is start solving inside the 'Brackets'.

For Example; (6 + 4) × 5
First solve inside ‘brackets’ 6 + 4 = 10, then 10 × 5 = 50.


Next solve the mathematical 'Of'.

For Example; 3 of 4 + 9
First solve ‘of’ 3 × 4 = 12, then 12 + 9 = 21.


Next, the part of the equation is to calculate 'Division' and 'Multiplication'.
We know that, when division and multiplication follow one another, then their order in that part of the equation is solved from left side to right side.

For Example; 15 ÷ 3 × 1 ÷ 5

Multiplication’ and ‘Division’ perform equally, so calculate from left to right side. First solve 15 ÷ 3 = 5, then 5 × 1 = 5, then 5 ÷ 5 = 1.


In the last part of the equation is to calculate 'Addition' and 'Subtraction'. We know that, when addition and subtraction follow one another, then their order in that part of the equation is solved from left side to right side.

For Example; 7 + 19 - 11 + 13

Addition’ and ‘Subtraction’ perform equally, so calculate from left to right side. First solve 7 + 19 = 26, then 26 - 11 = 15 and then 15 + 13 = 28.

These are simple rules need to be followed forsimplifying or calculating using BODMAS rule.


In brief, after we perform "B" and "O", start from left side to right side by solving any "D"or "M" as we find them. Then start from left side to right side solving any "A" or "S" as we find them.

How to use BODMAS rule

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test {

    public static void main(String[] args) {
        String orgString = "(3+4)*(7/2)";
        System.out.println(findValueInBraces(orgString));

    }

    public static String findValueInBraces(String finalStr) {

       while (finalStr.contains("(") && finalStr.contains(")")) {

            int fIndex = finalStr.indexOf("(");
            int nIndex = finalStr.indexOf(")");
            String subString = finalStr.substring(fIndex + 1, nIndex);
            

            finalStr = finalStr.substring(0, fIndex) + calculate(subString) + finalStr.substring(nIndex +1, finalStr.length());
        }
        return calculate(finalStr);

    }

    public static String calculate(String finalString) {

        while (finalString.contains("(") && finalString.contains(")")) {
            findValueInBraces(finalString);
        }
        while (!isNum(finalString)) {
            List<Integer> positions = getOperandPosition(finalString);
            int pos = positions.get(0);
            if (positions.size() >= 2 && positions.get(1) != null) {
                int nxtPos = positions.get(1);
                finalString = getValue(finalString.substring(0, nxtPos), pos)
                        + finalString.substring(nxtPos, finalString.length());
            } else {
                finalString = getValue(
                        finalString.substring(0, finalString.length()), pos);
            }
        }
        return finalString;

    }

    public static boolean isNum(String str) {
        if (str.contains("+") || str.contains("-") || str.contains("*")
                || str.contains("/")) {
            return false;
        }
        return true;
    }

    public static List<Integer> getOperandPosition(String str) {

        List<Integer> integers = new ArrayList<Integer>();

        if (str.contains("+")) {
            integers.add(str.indexOf("+"));
        }

        if (str.contains("-")) {
            integers.add(str.indexOf("-"));
        }

        if (str.contains("*")) {
            integers.add(str.indexOf("*"));
        }

        if (str.contains("/")) {
            integers.add(str.indexOf("/"));
        }

        Collections.sort(integers);
        return integers;
    }

    public static String getValue(String str, int pos) {
        double finalVal = 0;
        double a = Double.parseDouble(str.substring(0, pos));
        double b = Double.parseDouble(str.substring(pos + 1, str.length()));
        char c = str.charAt(pos);

        if (c == '*') {
            finalVal = a * b;
        } else if (c == '/') {
            finalVal = a / b;
        } else if (c == '+') {
            finalVal = a + b;
        } else if (c == '-') {
            finalVal = a - b;
        }
        return String.valueOf(finalVal);
    }
}

Wednesday 10 September 2014

Pagination in Visualforce Page (Add Next, Previous button on Visualforce page )

Here is some code snippet for the Pagination in Visualforce page.
We have to use StandardSetController for that.

Here we go-
Visualforce page: 

<apex:page controller="Pagination_min">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="1" >
            <apex:pageBlockTable value="{!accounts}" var="a">
               <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
                <apex:column value="{!a.BillingCity}"/>
                <apex:column value="{!a.BillingState}"/>
                <apex:column value="{!a.BillingCountry}"/>
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
            <apex:commandButton value="|<" action="{!setcon.first}" disabled="{!!setcon.hasPrevious}" title="First page"/>
            <apex:commandButton value="<" action="{!setcon.previous}" disabled="{!!setcon.hasPrevious}" title="Previous page"/>
            <apex:commandButton value=">" action="{!setcon.next}" disabled="{!!setcon.hasNext}" title="Next page"/>
            <apex:commandButton value=">|" action="{!setcon.last}" disabled="{!!setcon.hasNext}" title="Last page"/>
           
             <apex:outputText >{!(setCon.pageNumber * size)+1-size}   -    {!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton value="Refresh" action="{!refresh}" title="Refresh Page"/>
             
            </apex:panelGrid>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
 

</apex:page>



Custom Controller-

public class Pagination_min {

    Public Integer noofRecords {get; set;}
    public integer size {get; set;}
   
    public Apexpages.standardsetController setcon{
        get{
            if(setCon == null){
                size = 10;
                String queryString = 'Select Name, Type, BillingCity, BillingState, BillingCountry from Account order by Name';
                setcon = new apexpages.standardsetController(Database.getquerylocator(queryString));
                setcon.setpagesize(size);
                noofRecords = setcon.getResultsize();
            }
            return setcon;
        }
         set;
    }
    Public list<Account> getAccounts(){
        list<Account> acclist = new list<Account>();
         for(Account ac : (list<Account>)setcon.getrecords()){
             acclist.add(ac);
         }
        return accList;
       
     
    }
   
    Public PageReference Refresh(){
       
        setcon=null;
        getAccounts();
        setcon.setpageNumber(1);
       
        return null;
    }
}


Just copy and paste this code and BOOM First, Next, Previous and Last buttons are start doing there work.

Wednesday 30 July 2014

Call Custom Button in Visualforce page without custom controller

Here Custom_Button is the name of my custom button on opportunity object.

<apex:page standardController="Opportunity" >
    <apex:form >
              <apex:commandButton value="Edit" action="{!URLFOR($Action.Opportunity.Custom_Button,Opportunity.id)}"/>
    </apex:form>
</apex:page>

Saturday 17 May 2014

Salesforce Spring'14 Release Dumps

1. How can an administrator customize reporting for users?
a. Hide report types from all users.
b. Limit the number of reports a single user can create.
c. Enable historical trending reports for campaigns.
d. Remove footer information from exported reports.

2. What option is available to a user when building a dashboard?
a. Group and name dashboard filter values.
b. Display data from multiple reports in a single component.
c. Add up to 50 components to a single dashboard.
d. Display fractions as percentages in a table component

3. How can Salesforce Files Sync be used?
a. Sync files between Salesforce and your computer.
b. Share files with users by profile or role.
c. Collaborate on files with Chatter users and groups.
d. Control which version of a file is visible to each user.

4. What can an administrator do using SalesforceA on a mobile device?
a. Assign a user to a custom profile.
b. Reset a users password.
c. Freeze a user.
d. Create a new user.
e. Assign a permission set to a user.

 
5. What is a capability of Salesforce Orders?
a. Orders can be created directly from an account or contract.
b. Account and contract fields on an order can be modified.
c. An order can be associated with multiple price books.
d. Reduction orders can be created to process product returns.


6. How can an administrator control access to the Salesforce1 mobile application?
a. Enforce IP restrictions for mobile devices.
b. Define which users have login access.
c. Create and assign a mobile configuration.
d. Assign the Mobile User a standard profile.

7. What is a capability of the Data Import Wizard?
a. Example import values are displayed to help with field mapping.
b. Records can be imported for all standard and custom objects.
c. An import file can be dragged into the wizard for uploading.
d. Field mappings can be saved and used in later imports.

8. How can an administrator customize reporting for users?
a. Enable historical trending reports for campaigns.
b. Hide report types from all users.
c. Limit the number of reports a single user can create.
d. Remove footer information from exported reports.
  

Thursday 15 May 2014

Salesforce Dev 401 Quiz


Salesforce Dev 401 Quiz


  1. Standard fiscal years can start on the first day of any month of the year ?

  2. True
    False

  3. The organization IDs of your sandboxes remain same each time your sandbox is refreshed

  4. True
    False

  5. An opportunity can have only one primary partner

  6. True
    False

  7. Which of the following is not a correct statement?

  8. Tags can be enabled by enabling Tags permission for the Organization
    Tags can be enabled by enabling Tags permission for the Profiles
    Tags can be added on the Records
    Tags can be accessed from the Sidebar component

  9. Encrypted fields are editable regardless of whether the user has the “View Encrypted Data” permiss

  10. True
    False

  11. Which of the following can not be done via Workflow ?

  12. Create a Task
    Create an Event
    Create an Email Alert
    Create an Outbound Message

  13. Roll Up Summary fields work in which kind of relationship ?

  14. Many to Many Relationship
    One to One Relationship
    Master - Detail Relationship
    Lookup Relationship

  15. Which functionality cannot be achieved by final rejection action in an Approval Process ?

  16. Change the status of a field to “Rejected”
    Send an email notification
    Unlock the record
    Delete the Record

  17. Which feature is used to Report on Historical Data ?

  18. Reports
    Dashboards
    Analytical Snapshot
    Mobile Lite

  19. Folders are used in Salesforce.com to store ?

  20. Reports, Dashboards, Documents and Email templates
    Reports, Dashboards and Documents
    Dashboards, Documents and Email templates
    Reports and Dashboards

Thank you For Taking Quiz....

Salesforce Dev 401 Certification Questions...


Salesforce Dev 401 (Dumps-3)




1. Which of the following are included in territory management?




A. Lead

B. Opportunity

C. Activity

D. All of the Above




Answers : b




2.Irreversible data loss can result from clicking Enable Territory Management from Scratch.




A. TRUE

B. FALSE




Answers : a





3.Which of the following is TRUE about connection finder


A. Connection Finder allows you to SMS Partners to find out if they are Salesforce customers


B. Connection Finder allows you to email surveys to find out if your partners are Salesforce customers


C. Connection Finder allows you to check whether the salesforce.com is LIVE or not


D. Connection Finder allows you to set up a Connection with your customers




Answers : b




4.__________ allows companies that sell through indirect sales channels to maximize the return on their channel investments and increase channel revenues


A. Partner Relationship Management


B. Customer Relationship Management


C. Service Management


D. None of the Above




Answers : a




5.Data is to be plotted against time. Which Dashboard component is best suited for this purpose


A. Bar chart


B. Line chart


C. Visual Force Page


D. Funnel Chart




Answers : b




6.An administrator notices there are too many duplicate records, numerous sharing rules, and a large number of manually shared records. Which situation may this be a symptom of?


A. Role hierarchy that has too few roles.


B. Sharing model that is too public.


C. Sharing model that is too private.


D. Object permissions on profiles that are too restrictive.




Answers : c




7. In Salesforce Territory Management, which statement describes how a territory hierarchy is different from a role hierarchy?


A. Territory hierarchy grants login access to all users in a territory.


B. Territory hierarchy supports assigning users to multiple territories.


C. Territory hierarchy automatically assigns users to sales teams in the territory.


D. Territory hierarchy gives users in a territory full edit access to all accounts in that territory.




Answers : b




8. An administrator wrote a field update action for a workflow rule on a field that is hidden via Field- Level Security. When the workflow rule triggers, what happens to the data in the hidden field?


A. The field will fail to update and remain in its original state.


B. The field is updated, even though it is hidden.


C. The field will only update if the rule was triggered by a time-based trigger.


D. The field will only update if the user has “Modify All Data” enabled in the profile.




Answers : b




9. A developer wants to create a mashup to display a contact’s location using Google Maps. Which of the following is not a necessary step in developing this mashup?


A. Deciding on the parameters needed for submission


B. Creating an S-control to pass the URL to Google Maps


C. Creating a URL with merge fields to pass to Google Maps


D. Coding the HTML/JavaScript in an S-control to retrieve the results




Answers : d




10. A company called Universal Containers would like to track bugs within Salesforce. The company needs to track the bug’s severity and type as well as its status and description. Bugs should be related to cases, but the bug’s owner will be different than the owner of the case. How can the Universal Containers administrator meet these requirements?


A. Create a section on the case page layout


B. Create a field on cases


C. Create a custom object for bugs and relate it to cases


D. Create a relationship between the standard bug object and the standard case object.




Answers : c




11. A company currently uses the standard Salesforce CRM product and pricebook objects. Is it possible for this company to publish product and pricebook information to its corporate Web site so customers in different regions see the correct product catalog with prices in the local currency?


A. Yes, with the customer portal.


B. No, it is not possible to present multicurrency data.


C. Yes, by building a custom integration following the X-to-Web design pattern.


D. No, it is not possible to present data stored in standard objects other than cases and solutions to a Web site.




Answers : c

Wednesday 14 May 2014

Salesforce Dev 401 Certification Questions...

Salesforce Dev 401 (Dumps-2)

1. What is a junction object?
a. Object with lookup relationship
b. Master detail relationship
c. Object with two lookup relationships
d. Object with two Master-Detail relationships

Ans. d

2. In a Master-Detail relationship, what happens when the a record is deleted from the parent object?
a. Parent record alone gets deleted
b. Exception occurs
c. Parent and child record will not be deleted
d. All child records are deleted


Ans. c

3. Object X has a lookup to object Y. Which of the following statements are TRUE? Please choose two (2).
a. Fields of both X and Y are accessible from object Y
b. Fields of object Y can be accessed from object X
c. Fields of both Y and X are accessible from object X
d. Fields of object X can be accessed from object Y

Ans. b,c

4. What are the components of the dashboard that use grand totals? Please choose two (2) items.
a. Chart
b. Metric
c. Table
d. Gauge

Ans. b,d

5. How do you highlight totals in a report?
a. Roll-up summary field
b. Formula field
c. Custom summary field
d. Summary totals

Ans. d

6. In Master-Detail relationship scenario the fields of the parent object need to be displayed in the related list. How will a developer design this?
a. Cross-object formula field
b. Workflow rule
c. Validation rule
d. Assignment rule

Ans. a

7. What field can be controlled by a translation workbench?
a. Rule criteria
b. Formula
c. Validation errors
d. Assignment rules

Ans. d

8. What will cause the analytic snapshots run to fail? Please select three (3) choices.
a. The source report has been deleted
b. The target object has a trigger on it
c. The running user has been inactivated
d. The target object is a custom object
e. The source report is saved as matrix report

Ans. a,b,c

9. How does Salesforce enforce data access using role hierarchy?
a. Users are given access to the records owned by the users who are below them in the role hierarchy
b. Users are given access to the records owned by the users who share the same role in the role hierarchy
c. Users are given access to the records accessible by the users who are below them in the role hierarchy
d. Users are given access to the records accessible by the users who are above the role hierarchy

Ans. a

10. When you create a custom tab for a custom object, what are the features that are available by default? Please select two (2) choices.
a. Sidebar search object
b. Custom reporting
c. Recent Items
d. Ability to track activity

Ans. a,c

11. In a recruiting application a position that is of type critical should not be kept open for more than 14 days. How will you develop the business logic to cater to this?
a. Time-dependant workflow action to send an e-mail to the owner after 14 days
b. Time-dependant workflow action to send the record for review to owner after 14 days
c. Time-dependant workflow action to send an e-mail to the owner before 14 days
d. Time-dependant workflow action to close the position after 14 days

Ans. a

12. A job application object has a child review object to store candidate reviews. The review needs to be tracked between a score of 1 to 5. The score has to be a choice between 1 and 5 displayed as a radio button. How will a developer cater to this requirement?
a. Create 5 fields for scores (1 to 5) of type radio-button and use it in review page layout
b. Create a dependent picklist that feeds the radio button type field
c. Create a formula field
d. Create a Visualforce page with radio buttons for the review object

Ans. d

13. In a data model object A is related to B, B is related to C. How will a developer create a report to include fields of A and C?
a. Create lookup relationships between A,B and C
b. Create a custom report type with A, B and C, and use it in the report
c. Create a custom report with A and C fields as relationships already exist
d. Report cannot be created

Ans. b

14. An application was designed without considering whether requirements for reports include dashboards. Out of the following statements which one is TRUE?
a. The data model will support all the requirements of the application, including reports and dashboards
b. Reports are part of the application and application design will take care of it
c. No special considerations for reports or dashboards are required as Salesforce can natively take care of the requirements
d. The data model and the application will not cater for reports and dashboards

Ans. d

15. A recruiting application has a position object that contains location, department and other information relating to a position. We need to create a report that is grouped by department but not by locations. What is the best type of report a developer would choose?
a. Summary report
b. Tabular report
c. Matrix report
d. A report using Visualforce

Ans. a

Salesforce Dev 401 Certification Questions...

Salesforce Dev 401 (Dumps-1)

1. Standard fiscal years can start on the first day of any month of the year ?
A.True
B.False

Ans. A

2. The organization IDs of your sandboxes remain same each time your sandbox is refreshed
A. TRUE
B. FALSE

Ans. B

3. An opportunity can have only one primary partner
A. TRUE
B. FALSE

Ans. a

4. Which of the following is not a correct statement?
A. Tags can be enabled by enabling Tags permission for the Organization
B. Tags can be enabled by enabling Tags permission for the Profiles
C. Tags can be added on the Records
D. Tags can be accessed from the Sidebar component

Ans. b

5. Encrypted fields are editable regardless of whether the user has the “View Encrypted Data” permission.
A. True
B. False

Ans. A

6. Which of the following can not be done via Workflow ?
A.Create a Task
B.Create an Event
C.Create an Email Alert
D.Create an Outbound Message

Ans. b

7. Roll Up Summary fields work in which kind of relationship ?
A.Many to Many Relationship
B.One to One Relationship
C.Master - Detail Relationship
D.Lookup Relationship

Ans. c

8. Which functionality cannot be achieved by final rejection action in an Approval Process ?
A.Change the status of a field to “Rejected”
B.Send an email notification
C.Unlock the record
D.Delete the Record

Ans. D

9. Which feature is used to Report on Historical Data ?
A.Reports
B.Dashboards
C.Analytical Snapshot
D.Mobile Lite
E.Entitlements

Ans. C

10. Folders are used in Salesforce.com to store ?
A.Reports, Dashboards, Documents and Email templates
B.Reports, Dashboards and Documents
C.Dashboards, Documents and Email templates
D.Reports and Dashboards

Ans. A

11. Which of the following can be done by the Pagelayout Editor ?
A.Make a Field Mandatory
B.Make a Field Read-Only
C.Both A & B
D.None of Above

Ans. c

12. Which of the following is not allowed ?
A.Master (Custom object) and Detail (Standard object)
B.Master (Custom object) and Detail (Custom object)
C.Look Up between (Standard object) and (Standard object)
D.Look Up between (Standard object) and (Custom object)

Ans. A

13. How many different Master – Detail relationships can exist on the detail object side ?
A.1
B.2
C.3
D.4

Ans. B

14. What happens when a parent record is deleted in the Parent Child model having a Lookup Relationship between Parent - Child Objects ?
A.Child records are also deleted
B.Shows an error
C.Cant delete the record
D.Child records are not deleted

Ans. d

15. Can Data Loader be run through the Command Line ?
A.Yes
B.No

Ans. A

Friday 9 May 2014

Creating an Apex Class Using the Developer Console

Creating an Apex Class Using the Developer Console...


1. Click Your Name > Developer Console to open the Developer Console.

2. Click File > New > Apex Class.

3. Enter HelloWorld for the name of the new class and click OK.

4. A new empty HelloWorld class is created. Add a static method to the class by

adding the following text between the

braces:

public static void sayYou() {

System.debug( 'You' );
}
5. Add an instance method by adding the following text just before the final closing brace:
public void sayMe() {
System.debug( 'Me' );
}

6. Click Save.


You’ve created a class called HelloWorld with a static method sayYou() and an
instance method sayMe() . Looking at the definition of the methods,
you’ll see that they call another class, System , invoking the method debug() on that class, which will output strings.

If you invoke the sayYou() method of your class, it invokes the debug() method of the System class, and you see the output.


 
Now How To Calling a Class Method

Now that you’ve created the HelloWorld class, follow these steps to call its methods.

1. Execute the following code in the Developer Console to call the HelloWorld
class's static method.
 You might have to delete any existing code in the entry panel. Notice that to call a static method, you don’t have to create an instance of the class. HelloWorld.sayYou();

2. Open the resulting log.

3. Set the filters to show USER_DEBUG events. (Also covered in Tutorial 2). “You” appears in the log

4. Now execute the following code to call the HelloWorld class's instance method. Notice that to call an instance method,
you first have to create an instance of the HelloWorld class.
HelloWorld hw = new HelloWorld();
hw.sayMe();

5. Open the resulting log and set the filters.

6. “Me” appears in the Details column. This code creates an instance of the HelloWorld class, and assigns it to a variable
called hw . It then calls the sayMe() method on that instance.

7. Clear the filters on both logs, and compare the two execution logs. The most obvious differences are related to creating
the HelloWorld instance and assigning it to the variable hw . Do you see any other differences?

Congratulations—you have now successfully created and executed new code on the Force.com platform!

Thursday 8 May 2014

Integrate Google Map with Visual Force




Go to Your Name » Setup » Develop » Pages

Copy/paste the following code into a new Page replacing what appears by default.  Notice that in this example we're using custom fields for the Account address components:

<apex:page standardController="Account">
<apex:pageBlock >
<head>
 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 
 
$(document).ready(function() {
  
  var myOptions = {
    zoom: 20,
    mapTypeId: google.maps.MapTypeId.HYBRID,
    mapTypeControl: true
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.Project_Street_Address__c}, " + "{!Account.Project_City__c}, " + "{!Account.Project_Zipcode__c}";
  
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b>"
  });
 
  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }
  
});
</script>
 
<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:500px;
  background:transparent;
}
</style>
 
</head>
 
<body>
<div id="map"></div> 
</body> 
</apex:pageBlock>
</apex:page>

How To use Extensions In Visualforce page in Salesforce


Visualforce page


<apex:page standardController="Account" extensions="myextension">
    <p>{!title}</p>   
    <apex:form >
        <apex:inputField value="{!account.name}"/>

        <apex:commandButton value="Save" action="{!save}"/>
    </apex:form>
</apex:page>


extensions



public class myextension {
    private final account ac;
   
    public myextension(Apexpages.standardcontroller controller){
        this.ac =(Account)controller.getRecord();
    }
    public String getTitle(){
        return 'Account:' + ac.name + '(' + ac.id + ')';

    }
}





How To view or update three objects records in one visualforce page through custom controller




Visualforce page code

<apex:page controller="threeobjects">
    <apex:pageBlock >
    <apex:form >
    <apex:inlineEditSupport />
        <apex:pageBlockSection columns="3" >
            <apex:pageBlockTable value="{!accountname}" var="a">
                <apex:column headerValue="Accounts" >
                <apex:outputField value="{!a.name}"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!contactname}" var="c">
                <apex:column headerValue="Contacts" >
                <apex:outputField value="{!c.name}"/>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!opportunityname}" var="o">
                <apex:column headerValue="Opportunities" >
                <apex:outputField value="{!o.name}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlockSection>
  
        <apex:commandButton value="Save" action="{!save}"/>
        </apex:form>
    </apex:pageBlock>
</apex:page>




Controller

public class threeobjects {
    public list<account> accountname{get; set;}
    public list<contact> contactname{get;set;}
    public list<opportunity> opportunityname{get; set;}

    public threeobjects(){
        accountname = [select name from account limit 10];
        contactname = [select name from contact limit 10];
        opportunityname = [select name from opportunity limit 10];
    }
    public PageReference save() {
        update accountname;
        update contactname;
        update opportunityname;
        return null;
    }
}