Blog

  • Creating multiple tabs for same Salesforce Object

    Many time I have seen Salesforce Admins wants multiple tabs for same object depending upon the RecordTypes or some other criteria like separate tabs for Premium Account, Gold Accounts and Silver. Indeed they can create multiple views and use the picklist and use “Go” button. But it has disadvantage like multiple clicks, not that user friendly.

    In short there is no direct way of creating multiple tabs for same object in Salesforce. Then I thought of creating an Apex component which will take some inputs like ObjectName, Fields to display and criteria/Filter. This appraoch was needing too much of coding and generic code writing for supporting it for all objects. And it was limited to the query filter one can have.

    Creating multiple views is the feature inbuilt provided by the Salesforce and is very powerful. So I thought to use the apex:enhancedList control which takes the viewId as a parameter. You can find the documentation for the EnhancedList here. The most important thing is apex:enhancedlist only requires the viewid.

    I created a simple VisualForce Page like below.

    <apex:page >
    <apex:enhancedList height=”600″ rowsPerPage=”25″ id=”AccountList” listid=”{!$CurrentPage.Parameters.viewId}” customizable=”false”/>
    </apex:page>

    I wanted to reuse this page so I didn’t added any standard controller to the Page itself.

    Then now comes the step of creating the Tabs. Sample purpose I am taking Account’s views.

    Salesforce support following three types of tab creation:

    1. Custom Object Tabs: – Not suitable to above approach.
    2. VisualForce Tabs: – This will work but do not allow passing the parameters from the URL, so this will not allow reuse of the same page.
    3. Web Tabs: – This allows any URL integration into the tab and suits requirement.
    Complex task is to find the viewId. I didnt found it straight forward.
    Creating the Tab now:
    Now add this tab to your SelectedTabs.
    AS ITS A WEB TAB I WAS NOT ABLE TO SET SELECTED TAB. ANY WORK AROUND?

    3 responses to “Creating multiple tabs for same Salesforce Object”

    1. Terry Avatar
      Terry

      Nice tip! Thanks for sharing.

    2. Sochy Avatar
      Sochy

      This is an awesome tip! Thanks for sharing

    3. Michael Taylor Avatar
      Michael Taylor

      I think I have come up with a parallel solution that may work as well (better for me). Like the above you can distinguish the page with ANY view, whether using record type, or any other criteria.

      I created a visualforce page with an enhanced list, but used only the one object in the list that I want the tab for. The advantage here is that in the enhanced list, you can specify the list you want to display.

      Example of VF page:

      [YOUR NAME HERE]

      From there you can just create a VF tab with the way you want to identify it (probably same name as the tab). The page then doesn’t even show the option to change views – it’s as if it is its own object from the other views.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Salesforce: Adding specific working days to a Date

    UPDATE: If you want to consider holidays and business hours you can check out this article.

    Many time while coding we come across the requirement in which we need to calculate the EndDate from a StartDate after a specific number of business/working days. That means excluding the weekends (Saturday & Sunday) Following is the code snippet which does this. I know there can be an optimized way of doing this. But I didn’t want to spend more time on this.

    Below method takes date and number of working days to be added to the date.

    https://gist.github.com/prasannadeshpande/b56d3d78fb461fa7b27e5462e7543ac4

    Method daysOff calculates the number of non-working days coming in the start date and end date. And after which we are again adding those number of days.

    6 responses to “Salesforce: Adding specific working days to a Date”

    1. Ivo Gonzaga da Silva Avatar

      Hi Prasanna . I’m veryt thanks for your colaboration in Salesforce Code.
      If you have material about the basic treene, please send for me
      SilvaG

    2. Simon Lawrence Avatar

      It should be noted this snippet does not take into account national/bank holidays, it just excludes weekends days. Otherwise, very nice.

    3. Chirag Avatar
      Chirag

      Hi

      After adding daysOff to the endDate what if the date comes out to be a weekend?
      You’ve not handled that situaution.

      1. Prasanna Avatar
        Prasanna

        Hi Chirag, Current code should be handling it. 🙂

    4. Salman Khoja Avatar

      Hi If I want to exclude Fri and Sat as weekends and modify this formula so that it calculates the number of working days instead of a date, what changes do I need to make to this formula?

    5. Avi Avatar
      Avi

      Hi can You provide it in the form of A Trigger

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • I am “Monthly top contributor of month August” on Force.com Forum

    Monthly top contributors summary

    http://blog.sforce.com/sforce/2010/09/monthly-top-contributors-summary.html

    2 responses to “I am “Monthly top contributor of month August” on Force.com Forum”

    1. sharad Avatar
      sharad

      Thanks for answering my query. i have few more basic queries. can iask you if you provide me ur email plz?

    2. Prasanna Avatar
      Prasanna

      My email id prasuATprasannadeshpande.com

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.