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