Tag Archives: SFDC

Get Key Prefix of Salesforce Object

Let’s say we have a custom object “Customer__c”, and we want the Key Prefix of this object.

Using Apex:

String keyPrefix result = Customer__c.SObjectType.getDescribe().getKeyPrefix();
System.Debug('Key Prefix: ' + keyPrefix);

Using Workbench:
Login to Workbench || Info || Standard & Custom Objects || Select one object from the picklist || Expand Attributes

Big Objects in Saleforce

What is Big Object?

  • Big Object means 100s of billions of record on AppCloud.
  • It is a new capability with highly scalable object to store and manage large amount of data on the Salesforce platform.
  • This feature helps to engage directly with customers by preserving all your historical customer event data.
  • Big Objects are built by Salesforce to provide consistent performance whether there is 1 million records, 100 million, or even 10 billion records.

Use Cases:

  • Audit and Tracking: Track and maintain a long-term view of your user’s usage of Salesforce or your customer’s usage of your products for analysis or compliance purposes.
  • 360 view of Customers: Now data models can be extended to contain billing infos/ecommerce transactions/any other info related to customers.
  • Historical Data Archive: Maintain access to historical data for analysis or compliance purposes while optimizing the performance of your core CRM or Force.com applications.

Considerations:

  • It is provided as a pilot to selected premium customers.
  • The Big Objects cannot be created from the UI. We have to take help of the Metadata APIs to create one.
  • Big Objects don’t support triggers however they support object and field permissions.
  • BigObject don’t support standard UI elements (Home Pages, Detail Pages, List Views), But It can be used in Visualforce Page and Lightning components.
  • Data can be populated to the Big Objects via SFDC APIs/Bulk APIs/using Apex(insertImmediate() method).
  • The only SOQL relationship queries available are based on a lookup field from a BigObject to a standard or custom object.
  • Mostly Async SOQL would be used for the querying the Big Objects. Single level child-to-parent relationship queries and aggregate queries are supported.
  • Big Objects don’t support transactions.
  • We can create up to 100 Big Objects per org. The limits for BigObject fields are similar to the limits on custom objects, and depend on your org’s license type.
  • Big Objects don’t appear in the Setup UI until they are deployed.
  • Big Objects don’t appear in Salesforce1.

Generic Loading Component For Visualforce Pages

Visualforce Page Component:

<apex:component>
    <apex:actionStatus onstart="startLoading();" onstop="stopLoading();" id="loadStatus" />
    <style>
        .overlay {
            display: none;
            height: 100%;
            left: 0;
            position: fixed;
            top: 0;
            opacity: 0.3;
            -moz-opacity: 0.3;
            width: 100%;
            -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
            filter: alpha(opacity=30);
            background: #000;
            -khtml-opacity: 0.3;
            z-index: 1000;
        }

        .loader {
            background: url('/img/loading32.gif') scroll no-repeat 0 0;
            width: 32px;
            height: 32px;
            position: absolute;
            left: 50%;
        }
    </style>

    <div id="load_scrl" class="loadingBox loader" style="display:none"> </div>
    <div class="loadingBox overlay"> </div>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">

        function startLoading() {
            $('#load_scrl').css('top', $(document).scrollTop() + 200);
            $('.loadingBox').show();
        }

        function stopLoading() {
            $('.loadingBox').hide();
        }
    </script>
</apex:component>

Now add this component in your Visualforce Page:

<c:LoadingIcon/>

Use the “Status” attribute with the value “loadStatus” on the command button as follows:

<apex:commandButton action="{!save}" value="Save" status="loadStatus" rerender="myForm"/>

Use in Javascript:

startLoading(); //Start Loading
stopLoading() ; //Stop Loading

Get The Week Number of Month From Date in Salesforce

public Integer weekOfMonth(Date todaysDate){
        Integer weekCount = 0;
        Integer startWeekResidue = 0;
        Integer endWeekResidue = 0;
        
        //Calculating startWeekResidue
        Date dt = todaysDate.toStartOfMonth().addDays(-1);
        Date dtFirstWeekend = dt.toStartOfWeek().addDays(6);
        startWeekResidue = dt.daysBetween(dtFirstWeekend);
        
        //Calculating endWeekResidue
        Date dtLastWeekend = todaysDate.toStartOfWeek().addDays(-1);
        endWeekResidue = dtLastWeekend.daysBetween(todaysDate);
        
        //Counting the weeks
        weekCount = (todaysDate.day() - (startWeekResidue + endWeekResidue))/7;
        weekCount += (startWeekResidue > 0 ? 1:0)+(endWeekResidue > 0 ? 1:0);
        System.Debug('Week Number: ' + weekCount);
        return weekCount;
}

Example: Pass Parameter: 13Sept2017 – Output: 3

Salesforce Object Key Prefix List

Every ID in Salesforce is either 15 characters or 18 characters (API). The first 3-digits of the ID are always the Entity ID which can be used to determine the type of the entity.

For example, an Account record with ID “001D000000IBVzo” has the prefix “001” on NA1 which has server ID ‘D0’:

Below is the Object Key Prefix List:

Object Type Key Prefix
ACCOUNT ‘001’
QUOTE ‘0Q0’
NOTE ‘002’
CONTACT ‘003’
USERS ‘005’
OPPORTUNITY ‘006’
ACTIVITY ‘007’
OPPORTUNITY_HISTORY ‘008’
FORECAST_ITEM ’00A’
FILTER ’00B’
DELETE_EVENT ’00C’
ORGANIZATION ’00D’
USER_ROLE ’00E’
QUEUE ’00G’
GROUPS ’00G’
PARTNER ’00I’
OPPORTUNITY_COMPETITOR ’00J’
OPPORTUNITY_CONTACT_ROLE ’00K’
CUSTOM_FIELD_DEFINITION ’00N’
REPORT ’00O’
ATTACHMENT ’00P’
LEAD ’00Q’
IMPORT_QUEUE ’00S’
TASK ’00T’
EVENT ’00U’
EMAIL_TEMPLATE ’00X’
EMAIL_TEMP ’00Y’
COMMENTS ’00a’
CUSTOM_RESOURCE_LINK ’00b’
TRAINING ’00c’
PROFILE ’00e’
MH_BLUESHEET ’00f’
MH_GOLDSHEET ’00g’
LAYOUT ’00h’
PRICEBOOK_MAPPING ’00i’
PRICEBOOK_ENTRY_MAPPING ’00j’
OPPORTUNITY_LINEITEM ’00k’
FOLDER ’00l’
EMAIL_ATTACHMENT_LOOKUP ’00m’
EMAIL_ATTACHMENT_ARCHIVE ’00n’
LINEITEM_SCHEDULE ’00o’
USER_TEAM_MEMBER ’00p’
OPP_TEAM_MEMBER ’00q’
ACC_SHARE ’00r’
ACC_SHARE_DEFAULT ’00s’
OPP_SHARE ’00t’
OPP_SHARE_DEFAULT ’00u’
CAMPAIGN_MEMBER ’00v’
PAYMENT_APPLICATION ’00w’
BILLED_PRODUCT ’00x’
PURCHASE_RULE ’00y’
PURCHASE_RULE_ENTRY ’00z’
CASE_SOLUTION ‘010’
GROUP_MEMBER ‘011’
RECORD_TYPE ‘012’
RECORD_TYPE_PICKLIST ‘013’
PROFILE_RECORD_TYPE ‘014’
DOCUMENT ‘015’
BRAND_TEMPLATE ‘016’
ENTITY_HISTORY ‘017’
EMAIL_STATUS ‘018’
BUSINESS_PROCESS ‘019’
BUSINESS_PROCESS_PICKLIST ’01A’
LAYOUT_SECTION ’01B’
LAYOUT_ITEM ’01C’
PROFILE_LAYOUT ’01G’
MAILMERGE_TEMPLATE ’01H’
CUSTOM_ENTITY_DEFINITION ’01I’
PICKLIST_MASTER ’01J’
CURRENCY_TYPE ’01L’
ACC_TEAM_MEMBER ’01M’
ACTIVE_CONTENT ’01N’
USER_UI_CONFIGURATION ’01O’
PROFILE_TAB_CONFIGURATION ’01P’
WORKFLOW_RULE ’01Q’
RULE_FILTER ’01R’
RULE_FILTER_ITEM ’01S’
RULE_FILTER_ACTION ’01T’
ACTION_ASSIGN_ESCALATE ’01U’
ACTION_TASK ’01V’
ACTION_EMAIL ’01W’
ACTION_EMAIL_RECIPIENT ’01X’
CAMPAIGN_MEMBER_STATUS ’01Y’
DASHBOARD ’01Z’
DASHBOARD_COMPONENT ’01a’
FILTER_ITEM ’01b’
FILTER_COLUMN ’01c’
FOLDER_GROUPS ’01d’
PICKLIST_SET ’01e’
WEBEX_MEETING ’01f’
API_QUERY ’01g’
TRANSLATION ’01h’
TRANSLATION_USER ’01i’
TRANSLATION_VALUE ’01j’
PROFILE_FLS_ITEM ’01k’
ACTION_RESPONSE ’01l’
BUSINESS_HOURS ’01m’
CASE_SHARE ’01n’
LEAD_SHARE ’01o’
CUSTOM_TAB_DEFINITION ’01r’
PRICEBOOK2 ’01s’
PRODUCT2 ’01t’
PRICEBOOK_ENTRY ’01u’
PRICEBOOK_SHARE ’01v’
OPP_UPDATE_REMINDER ’01w’
OPP_UPDATE_REMINDER_STATS ’01x’
CASE_SHARE_DEFAULT ’01y’
CASE_ESCALATION ’01z’
EVENT_ATTENDEE ‘020’
QUANTITY_FORECAST ‘021’
FISCAL_YEAR_SETTINGS ‘022’
APP_CALENDAR ‘023’
APP_CALENDAR_SHARING ‘024’
LIST_LAYOUT_ITEM ‘025’
PERIOD ‘026’
REVENUE_FORECAST ‘027’
OPPORTUNITY_OVERRIDE ‘028’
LINEITEM_OVERRIDE ‘029’
LEAD_SHARE_DEFAULT ’02A’
LABEL_DEFINITION ’02B’
LABEL_DATA ’02C’
CASES_HISTORY2 ’02D’
HELP_SETTING ’02E’
CUSTOM_FIELD_MAP ’02F’
MH_GOLD_PROGRAM ’02H’
MH_GOLD_INFORMATION ’02I’
MH_GOLD_CONTACT ’02J’
MH_GOLD_ACTION ’02K’
MH_CUSTOMER_CRITERION ’02L’
MH_GREENSHEET ’02M’
MH_GREEN_GIVE_INFO ’02N’
MH_GREEN_GET_INFO ’02O’
MH_CONTACT_ROLE ’02P’
MH_INFORMATION ’02Q’
USER_PREFERENCE ’02R’
HTML_COMPONENT ’02S’
CUSTOM_PAGE ’02T’
CUSTOM_PAGE_ITEM ’02U’
PAGE_COMPONENT ’02V’
CUSTOM_PAGE_PROFILE ’02X’
USER_COMPONENT_DATA ’02Y’
ACCOUNT_CONTACT_ROLE ’02Z’
CONTRACT_CONTACT_ROLE ’02a’
COMPONENT_RESOURCE_LINK ’02b’
DIVISION ’02d’
DIVISION_WORKFLOW_RULE ’02e’
DELEGATE_GROUP ’02f’
DELEGATE_GROUP_MEMBER ’02g’
DELEGATE_GROUP_GRANT ’02h’
ASSET ’02i’
PROFILE_ENTITY_PERMISSIONS ’02j’
LIST_LAYOUT ’02k’
OUTBOUND_QUEUE ’02l’
CUSTOM_INDEX ’02m’
CATEGORY_NODE ’02n’
CATEGORY_DATA ’02o’
DIV_TRANSFER_EVENT ’02p’
LAYOUT_ITEM_COLUMN ’02q’
OPPORTUNITY_ALERT ’02r’
EMAIL_MESSAGE ’02s’
EMAIL_ROUTING_ADDRESS ’02t’
TAB_SET ’02u’
TAB_SET_MEMBER ’02v’
LOGIN_IP_RANGE ’02w’
LOGIN_HOURS ’02x’
REPORT_AGGREGATE ’02y’
REPORT_COLOR_RANGE ’02z’
PROFILE_TAB_SET ‘030’
USER_TAB_SET_MEMBER ‘031’
ACC_TERRITORY_RULE ‘032’
PROJECT ‘033’
PROJECT_MEMBER ‘034’
SELF_SERVICE_USER ‘035’
JOB_QUEUE ‘036’
REPORT_COLUMN ‘037’
REPORT_FILTER_ITEM ‘038’
REPORT_BREAK ‘039’
DEPENDENT_PICKLIST ’03a’
PACKAGE_EXPORT ’03b’
LAYOUT_RIGHT_PANEL ’03c’
CUSTOM_SETUP_DEFINITION ’03e’
CUSTOM_SETUP ’03f’
REPORT_PARAM ‘040’
ACC_TERRITORY_ASSIGN ‘041’
ACC_TERR_ASSIGN_RULE_ITEM ‘042’
OUTBOUND_FIELD ‘043’
USER_TERRITORY ’04S’
TERRITORY ’04T’
DNB_ACCOUNT_MAPPING ’04U’
DNB_FIELD ’04V’
REVENUE_FORECAST_HISTORY ’04W’
QUANTITY_FORECAST_HISTORY ’04X’
CONTENTVERSION ‘068’
CONTENTDOCUMENT ‘069’
ENTITY_PERMISSION ‘110’
SFDC_PARTNER ‘204’
SFDC_DIVISION ‘208’
CASES ‘500’
SOLUTION ‘501’
BILLING_DIVISION 600′
BILLING_ORDER 601′
CURRENCY 602′
PLAN 604′
PRODUCT ‘605’
BILLING_ORDER_ITEM ‘606’
PLAN_PRODUCT ‘607’
CAMPAIGN ‘701’
FIELD_HISTORY ‘737’
UI_STYLE_DEFINITION ‘766’
UI_STYLE ‘777’
CONTRACT ‘800’
ORDERS ‘801’
ORDER_ITEM ‘802’
INVOICE ‘803’
INVOICE_ITEM ‘804’
PAYMENT ‘805’
APPROVAL ‘806’
URI_BLOCK_RULE ‘807’
CUSTOM_ENTITY_DATA ‘a00’
SERVICECONTRACT ‘810’
USERLICENSE ‘100’
CUSTOM_LABEL ‘101’
APEXCLASSMEMBER ‘400’
FORECASTSHARE ‘608’
ASYNCAPEXJOB ‘707’
APEXTESTQUEUEITEM ‘709’
BULK_QUERY_JOB ‘750’
BULK_QUERY_BATCH ‘751’
BULK_QUERY_RESULT ‘752’
REMOTE_ACCESS ‘888’
EMPTYKEY ‘000’
USERACCOUNTTEAMMEMBER ’01D’
APEXCLASS ’01p’
APEXTRIGGER ’01q’
SHARINGRULE ’02c’
VALIDATIONRULE ’03d’
QUEUESOBJECT ’03g’
CASECONTACTROLE ’03j’
CONTACTSHARE ’03s’
USERPERFERENCE ’03u’
PROCESSINSTANCE ’04g’
PROCESSINSTANCESTEP ’04h’
PROECESSINSTANCEWORKITEM ’04i’
OUTBOUND_MESSAGE_ID ’04k’
OUTBOUND_NOTIFICATION_ID ’04l’
ADDITIONALNUMBER ’04m’
ASYNCRESULT ’04s’
INSTALL_PACKAGE ’04t’
CALLCENTER ’04v’
FIELD_UPDATE ’04Y’
CONTENTWORKSPACE ‘058’
CONTENTWORKSPACEDOC ‘059’
DOCUMENTATTACHMENTMAP ’05X’
PORTAL_ID ‘060’
APEXPAGE ‘066’
SANDBOX ’07E’
APEXLOG ’07L’
APEXTESTRESULT ’07M’
STATICRESOURCE ‘081’
DATA_FROM_UNINSTALLED_PACKAGES ‘082’
VOTE ‘083’
IDEA ‘087’
CRONTRIGGER ’08e’
CAMPAIGNSHARE ’08s’
EMAILSERVICESFUNCTION ‘091’
WEEKLY_DATA_EXPORT ‘092’
EMAILSERVICEADDRESS ‘093’
APEXCOMPONENT ‘099’
COMMUNITY ’09a’
CHANGE_SET ‘0A2’
INSTALLED_PACKAGE ‘0A3’
CONNECTION_S2S ‘0BM’
HOLIDAY ‘0C0’
ORGWIDEEMAILADDRESS ‘0D2’
USERPROFLEFEED ‘0D5’
SITE ‘0DM’
ENTITYSUBSCRIPTION ‘0E8’
INBOUND_CHANGE_SET ‘0EP’
SETUPENTITYACCESS ‘0J0’
PERMISSION_SET_METADATA ‘0PS’
TAGDEFINITION ‘0t0’
LOGINHISTORY ‘0Ya’
METADATACONTAINER ‘1dc’
CONTAINERASYNCREQUEST ‘1dr’
TRACEFLAG ‘7tf’

Note: This list is not updated with every release.