Skip to main content

Posts

Showing posts from January, 2014

Test.loadData in TestMethod

Use Case -  Tired of writing many lines of codes just to create test data in test methods. Also, over the time, because of change in business requirement, you need to add/remove/modify fields from those test records. If yes, then Test.loadData() is best for you. Say we want to write a test method, in which we need to insert account records and its associated contact records. Before Test.loadData() , the only option was to create explicit account records insert them and then create contact records. Also you need to establish relation between account & contact records. If you need 1000 account & 2000 contact records, you can assume how many line of codes you need to write just for creation of test records. Solution -  Use Test.loadData() to create records using csv file and using just a single line of code. Taking above problem in mind, let us discuss how to do it. Let us first create a new field ( FakeId ) (API Name - FakeId__c ) on both Account & a new field

Big Objects in force.com platform

With Winter'14 salesforce introduced a feature called " Field History Retention ". It was in pilot and with Spring'14 release, it's still in pilot. It is first force.com feature that uses big data technologies. For more scalability, salesforce is working on big data technologies. And for this salesforce is working on new type of SObject ' Big Data '. Big objects are just like regular SObjects with more scalability, but less functionality. Platform is built on top of relation technology using Oracle as main data repository for multi tenant environment. Now for more scalability salesforce is working on multi tenant big data store using HBase , which is open source database. Salesforce is working on Phoenix project, which allows to run low latency queries on top of HBase . Initially Big Objects will come with let functionality and more scalability. When to use Big Object:- if record count > 100 millions can live with some platform

Deleting Components in Managed Packages

Starting Spring ‘14, ISVs can delete the following types of components when updating a previously released managed package. Custom Buttons or Links Custom Fields Custom Objects Custom Tabs Field Sets Record Types Validation Rules The deletion of these components was not supported previously, to avoid the risk of data loss or integration failures in subscriber organizations. However, the number of such components in a complex package can grow very large over multiple release cycles. The ability to delete managed components can be very useful in such cases. It gives ISVs greater flexibility in maintaining and upgrading their apps. Deleting any component will permanently delete any data that exists in that component, delete tracked history data, and change any integrations that rely on the component, such as assignment or escalation rules. Also, once you delete a component in a managed package, you can’t restore it or create another component with the same na

Polymorphic Relationship & SOQL Polymorphism

Problem:- In Event object, WhatId field can refer to ' Account ', ' Opportunity ', ' Campaign ', custom objects etc. I want to write a SOQL query which will return different set of fields based upon which object ' WhatId ' is referring to. Solution:- Before Winter'13 release,  you have to do extra work when making queries that involve polymorphic relationships. Since you don’t know in advance what type of object is being referenced, you might have to get the ID of a Name object instead, process this information in some logic code, and then do a second query using information from that Name object to get to the content of the referenced object. With Winter'13, salesforce has introduced the concept of Polymorphic SOQL . Polymorphic Relationship:-  A polymorphic relationship is a relationship where the referenced objects can be one of several different object types. For example, the What relationship field in an Event can referen

Custom Index on Deterministic Formula Field

Since the Winter ’13 release, you have been able to contact salesforce.com Customer Support to create a custom index on a formula field, provided that the function that defines the formula field is deterministic. Here are examples of common non-deterministic formulas. Force.com cannot index fields that: Reference other entities (i.e., fields accessible through lookup fields) Include other formula fields that span over other entities Use dynamic date and time functions (e.g.,  TODAY ,  NOW ) A formula is also considered non-deterministic when it includes: Owner, autonumber, divisions, or audit fields (except for CreatedDate and CreatedByID fields) References to fields that Force.com cannot index Multi-select picklists Currency fields in a multicurrency organization Long text area fields Binary fields (blob, file, or encrypted text) Standard fields with special functionalities Opportunity: Amount, TotalOpportunityQuantity, ExpectedRevenue, IsClosed, IsWon Cas

Add Salesforce project to a new Git repository

As a developer, when for first time, I thought of using Git as my central repository, I had no clue how to do it. After searching, I found that there are so many users who are looking for way to use Git with Salesforce project, but because of non-availability of guide, they can't. I was lucky to figure out how to do it. So below I am going to share first step i.e. how to push your code base to Git repository for the first time. Login to https://github.com Scroll down to find 'New Repository' link on the left bottom.  Click on 'New Repository' button and it will open  new repository butoon like below:-  Enter name of repository in 'Repository Name' box. Github will check if this name is already used, if not then it will let you use this name. You can select 'Public' or 'Private' based upon your requirement. For 'Private' repository you will need buy license. For simplicity I have keep my repository as 'Public'. Cl