Object sharing using Email approval in Salesforce

This solution gives record access to a Salesforce user via email approval. Here we are providing access to the Accounts but this can be generalized for any standard or custom object.
 In order to grant access to the Account, an approval workflow request would be sent to the record owner and upon approval Apex code would be executed to add the requested user in the Account Team/Share objects.
1    1.    Provide a Request for Access button against each Account record on the Visual force page.
a.      Display a pop-up to the end user: A Request Email has been sent for Access.
b.      Create a Custom Object “Account Sharing Request” and add an Entry in this object:
AccountID, OwnerID, RequestedBy(UserID),IsApproved(False) for the request.
2.      Create an Approval process for Account Sharing Request in the controller class and send an approval request email to the record owner. 
3.      Enable email approval response so that the user can approve or reject the request by replying to the email: approve, approved, yes, reject, rejected,or no.
4.      Update IsApproved field to True upon approval: This is the Final approval action.
5.      Update trigger on the Account_Sharing_Request__c object would add the requested User to the Account Team and Account share Object.


How to create RowID in Tables : Here is the Code or Script Code for ID creation

If you are looking for to How to create RowID in Tables : Here is the Code or Script Code for ID creation,
Find below a simple Script or Code for generating Row ID or Record ID in Tables for Salesforce
public void viewTracking(){
if(trackingRow != null){
list rowId = trackingRow.split(‘:’);
if(rowId.size() >1){
//system.debug(‘***’+ integer.valueof(rowId[(rowId.size()-2)]));
Tracking =orderDetails[integer.valueof(rowId[(rowId.size()-2)])].Tracking;
Using RowID can be helpful in many ways to identify a record, count the records, classify, add, insert or delete a record or row just with a command in Tables.

Hierarchy in VisualForce

Hierarchy in VisualForce is an interesting feature unique to VisualForce

This is an example of how to build a hierarchy Lists in VF page with select checkboxes. It will have a checkbox at parent level with which you can select all the child automatically. It has a neat link with which you can show or hide children under a parent row. It uses jquery libraries for achieving this. It has a list of accounts with each accounts displaying all its contacts in a hierarchy view.

Apex Class

public class accconhierarchy {
    Private list acc;
    public List accountList { get; set; }
    public accconhierarchy (){
        List cw;
        accountList = new List();
        acc = [select id,name,industry,billingcountry,createdbyid,(select id,name,email,phone from contacts) from account limit 20];
        for(account a:acc){
            cw = new list();
            For(contact co : a.contacts){
               cw.add(new contactWrap(co));
            accountList.add(new accountWrap(a,false,cw));
    public class accountWrap{
        public account oAccount{get;set;}
        public boolean isSelected{get;set;}
        public List contactset{get;set;}
        public accountWrap(account a,boolean b, List c){
            contactset =c;           
    public class contactWrap{
        public contact oContact{get;set;}
        public boolean isSelected{get;set;}       
        public contactWrap(contact a){

Visualforce Page






                                   Account Name


                                   Billing Country




                                            onclick=”javascript:toggleSelectAll(this, ‘{!$Component.repeatAccount}’);”/>






JS function toggleContactRow is used to show or hide contacts and toggleSelectAll is for header level checkbox at the parent Level.

SFDC API 24.0 test failure issue

Yesterday I was experiencing a weird issue. My SFDC API Test Failed.For a new requirement we did development in our DEV environment…We wrote new test methods and we thought the work is done :)…
However, there were Null Pointer Exceptionswhen we ran the test methods.
And it was pointing to the custom settings….we doubled checked and confirmed that the custom setting had the default values. Also, it was accessible to anyone (public).

After some time I realized that the test method API version was 24.0.. I changed it to 23.0 and there were no errors 🙂

Edit – SFDC has introduced test classes not to access data directly with API 24. Even though it is a good move , I would like to access certain info by default like custom settings, and Pricebook. But there is always an option to use @istest(seealldata=true) to access live data.


Cool links for SFDC Salesforce.com Tools and Best practices

I was going through the Best practices for force.com and Trigger template. It will be really helpful if we could follow it in our code.You can also find lots of interesting tools for salesforce.com here.

Found this awesome IDE and data loader on the cloud !!! – Workbench . I would have loved to have metadata export on this. If anyone knows a tool not an app through which we can export metadata (not like an XML) more like a spreadsheet which can be used for documentation and data mapping please drop a comment here.

Finally Vote for all the ideas in this link. These are all the features worth having in SFDC.

There are many a times where we need to mimic a standard page through VF. Creating them to mimic it is a hard thing. But it can be done with a single click , whole code gets generated.

You can check that out here. Pretty cool stuff aint it for SFDC Admins SFDC Developers.