Skip to main content

Posts

Showing posts from December, 2013

GROUP BY ROLLUP()

Use Case In one of my recent project, to achieve business objective I had to write a query to find total on the basis of certain criteria, say: GROUP BY Status, LeadSource . Further, I had to find subtotal on the basis of only Status. The solution which came on top of my mind was that get all records using a query something like: SELECT Status, LeadSource, COUNT(Name) cnt FROM Lead GROUP BY Status, LeadSource . And then loop through records and with the help of APEX , get the subtotals. As a developer, I can use collections to get my business objective. But I was curious to know if there is anything we can add in SOQL to get subtotals too.  Solution My curiosity took me to " GROUP BY ROLLUP() " option. With API version 18.0 and later, you can use GROUP BY ROLLUP to add subtotals for aggregated data in query results. This allows the query to calculate subtotals so you don't have to maintain that logic in your code. Use GROUP BY ROLLUP with aggregate functio

User Sharing - OWD for User Object Winter'14

Problem I am a manufacturer and I need to include all dealers in my organization while still keeping them from seeing each other. Solution   Before Winter'14 release, it was not possible. But with Winter'14 release, salesforce has introduced "User Sharing".  User Sharing enables you to show or hide an internal or external user from another user in your organization. Previously, User Sharing for external users was enabled by default with Communities, while User Sharing for internal users was available through  a pilot program. With Winter ’14, User Sharing is automatically enabled in new organizations. You can: Set the organization-wide defaults for user records to Private or Public Read Only. Create user sharing rules based on group membership or other criteria. Create manual shares for user records to open access to individual users or groups. Control the visibility of external users in customer or partner portals and communities. htt

Partial Data Sandbox

With Winter'14, salesforce has introduced a new sandbox type ' Partial Data Sandbox '. It will be fourth type of sandbox besides Developer Sandbox, Developer Pro Sandbox and Full Sandbox . Partial Data sandboxes include all of your organization’s metadata and add a selected amount of your production organization's data that you define using a sandbox template. A Partial Data sandbox is a Developer sandbox plus the data you define in a sandbox template. It includes the reports, dashboards, price books, products, apps, and customizations under Setup (including all of your metadata). Additionally, as defined by your sandbox template, Partial Data sandboxes can include your organization's standard and custom object records, documents, and attachments up to 5 GB of data and a maximum of 10,000 records per selected object. A Partial Data sandbox is smaller than a Full sandbox and has a shorter refresh interval. You can refresh a Partial Data sandbox every 5 days.

Grant Access Using Hierarchies

Problem There is a custom object say 'XYZ' and OWD for this is set to ' Private ', which means record of this can be seen by only owner and users above in role-hierarchy and territory. However, to share this with other user, we can manually share it. The problem is that I don't want other users, who are above in role-hierarchy and territory of the user with whom record has shared, can see it. Solution We can un-check ' Grant Access Using Hierarchies ' check box for object 'XYZ' on 'Sharing Settings' page. We can go to Setup >> Security Controls >> Sharing Settings and click on ' Edit ' button. On the edit page, we can un-check ' Grant Access Using Hierarchies ' for required object.  Major uses of 'Grant Access Using Hierarchies' are:- If you disable the Grant Access Using Hierarchies option, sharing with a role or territory and subordinates only shares with the users directly asso

Import GitHub Project in Eclipse

Use Case   There is a project going on and you join the team in between. Team is using Git for central repository. For you the starting point is to add git project in your Eclipse IDE and start development/enhancement/maintenance. Solution Pre-requisite - Eclipse having Force.com & egit plug-in installed. EGit plugin can be downloaded from http://www.eclipse.org/egit/download/ Steps to import your project from Github:- Go to Github.com and take URL of the project-   Open Eclipse IDE and go to New >> Import  Select 'Projects from Git' from pop-up window  Select URI and click 'Next'  Enter repo details as shown below. You only need to enter URL copied from GitHub for your project, 'Host' and 'Repository path' will be populated automatically. You will need to enter your github user name & password. Click on 'Next'.  From next screen, select all branches you want to have. To be safe, add all branches. Click

Hierarchical Relationship

Recently, I came across one of requirement where client wanted to have a custom lookup field on User object. This lookup will be on User. Based upon certain criteria, value of this field will go to Manager field. They didn't want update of Manager, but on the basis of some business use case. First impression to me was it will be straight forward to create a lookup on user and then in trigger will check for business use case and update Manager field accordingly. However, when I proceed with creating a look on User object, I couldn't find an option ' Lookup Relationship ' on first screen of 'New Custom Field'.  In fact, I saw only available option ' Hierarchical Relationship ' for creating any sort of relationship. I know most of us know about it. But you can't defer on my opinion that we tend to forget these small stuff. Since, on user you can't have any direct relationship, but only user. Salesforce gives you special relationship data t