Sunday 15 March 2015

Type of Sandbox in salesforce


Developer Sandbox
Developer sandboxes are special configuration sandboxes intended for coding and testing by a single developer. Multiple users can log into a single Developer sandbox, but their primary purpose is to provide an environment in which changes under active development can be isolated until they’re ready to be shared. Just like Developer Pro sandboxes, Developer sandboxes copy all application and configuration information to the sandbox. Developer sandboxes are limited to 200 MB of test or sample data, which is enough for many development and testing tasks. You can refresh a Developer sandbox once per day.

REFRESH LIMIT    :-  Daily
DATA LIMIT          :-  200MB


Developer Pro Sandbox
The main difference between this and Developer is the amount of data that can be stored.  It also grabs some product data from production.  If those two things are important, use this one.  Otherwise, it's interchangeble with Developer

Developer Pro sandboxes copy all of your production organization's reports, dashboards, price books, products, apps, and customizations under Setup, but exclude all of your organization's standard and custom object records, documents, and attachments. Creating a Developer Pro sandbox can decrease the time it takes to create or refresh a sandbox from several hours to just a few minutes, but it can only include up to 1 GB of data. You can refresh a Developer Pro sandbox once per day

REFRESH LIMIT    :-  Daily
DATA LIMIT          :-  1GB


Partial Copy
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.

REFRESH LIMIT    :-  5 Days
DATA LIMIT          :-  5GB


Full Sandbox
Full sandboxes copy your entire production organization and all its data, including standard and custom object records, documents, and attachments. You can refresh a Full sandbox every 29 days.
Sandbox templates allow you to pick specific objects and data to copy to your sandbox, so you can control the size and content of each sandbox. Sandbox templates are only available for Partial Data or Full sandboxes.

REFRESH LIMIT    :-  29 Days
DATA LIMIT          :-  Same as Production





Wednesday 11 March 2015

how to stop recursive trigger in salesforce

Problem :-  

1) Many Developers face recursive trigger , or recursive update trigger. For example in 'after update' trigger, Developer is performing update operation and this lead to recursive call.

2) You want to write a trigger that creates a new record ; however, that record may then cause another trigger to fire, which in turn causes another to fire, and so on. 

 
Solution :-

you can create a class with a static Boolean variable with default value true. In the trigger, before executing your code keep a check that the variable is true or not. Once you check make the variable false.


 Apex Class with Static Variable

public class ContactTriggerHandler
{
     public static Boolean isFirstTime = true;
}


Trigger Code

trigger ContactTriggers on Contact (after update)
{
    Set<String> accIdSet = new Set<String>(); 
    if(ContactTriggerHandler.isFirstTime)
    {
        ContactTriggerHandler.isFirstTime = false;
         for(Contact conObj : Trigger.New)
  {
            if(conObj.name != 'Test') 
     {
                accIdSet.add(conObj.accountId);
            }
         }
   // any code here
    }
}


Thursday 5 March 2015

Locking Statements FOR UPDATE

Apex allows you to lock sObject records while they’re being updated in order to prevent race conditions and other thread safety problems. While an sObject record is locked, no other client or user is allowed to make updates either through code or the Salesforce user interface.

Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];

NOTE:-
  1. While the records are locked by a client, the locking client can modify their field values in the database in the same transaction. Other clients have to wait until the transaction completes and the records are no longer locked before being able to update the same records. Other clients can still query the same records while they’re locked.
  2. If you attempt to lock a record currently locked by another client, you will get a QueryException. Similarly, if you attempt to update a record currently locked by another client, you will get a DmlException.
  3. If a client attempts to modify a locked record, the update operation might succeed if the lock gets released within a short amount of time after the update call was made. In this case, it is possible that the updates will
 You can’t use the ORDER BY keywords in any SOQL query that uses locking

Thanks,
Amit Chaudhary

Tuesday 3 March 2015

How to open a new record inside a console in SubTab by inline visual force page

Include JS in VF page


<apex:includeScript value="/support/console/26.0/integration.js"/>

Write below Java Script code in VF page


<script>

 var preRecordId;
        
        function testOpenSubtab(id, name) 
        {
            preRecordId= id;
            //First find the ID of the primary tab to put the new subtab in

            alert('URL----->'+'{!$CurrentPage.URL}');

             if (sforce.console.isInConsole())
                sforce.console.getEnclosingPrimaryTabId(openSubtab);
             else
              window.top.location.href = '/' + id;
        }
        
        var openSubtab = function openSubtab(result) 
        {
            //Now that we have the primary tab ID, we can open a new subtab in it
            var primaryTabId = result.id;
            
            sforce.console.openSubtab(primaryTabId , '/'+preRecordId , true, 
                preRecordId , null , openSuccess, 'salesforceSubtab');
        };
        
        var openSuccess = function openSuccess(result) 
        {
            //Report whether we succeeded in opening the subtab
            /*
                if (result.success == true) 
                {
                    alert('subtab successfully opened');
                } 
                else 
                {
                    alert('subtab cannot be opened');
                }
            */
        };
</script>


Then use below link to open new record .


 <a href="#" onclick="testOpenSubtab('{!Obj.id}', '{!Obj.id}');return false">{!Obj.customKey}</a>

Sunday 1 March 2015

How to open a new record inside a console by visual force page ( VF page ):- isInConsole()



Determines if the page is in the Salesforce consoleThis method is only available in API version 22.0 or later.


Solution :-

Include JS in VF page


<apex:includeScript value="/support/console/26.0/integration.js"/>

Write below Java Script code in VF page


<script>

function openTab(id, name) 
{
 if (sforce.console.isInConsole())
  sforce.console.openPrimaryTab(undefined, '/' + id + '?isdtp=vw', true, name);
 else
  window.top.location.href = '/' + id;
}

</script>


Then use below link to open new record .


<a href="#" onclick="openTab('{!Obj.id}''{!Obj.name}'); return false;">{!Obj.customKey}</a>