Friday, February 19, 2016

Global Picklist Feild in Salesforce

This feature we are going to discuss here is a Pilot/BETA version which is available only in some of the Editions as well as many features may not be available until Salesforce announces this feature through documentation or Press Releases or Public Statements.

As we already know that Salesforce has introduced a new feature called Global Picklist (BETA version) . These Global Picklist concept is similar to Global Actions concepts where create once and use many times across all objects.

Similarly these Global Picklist is nothing but a creating a Picklist field globally and use that picklist field values across the all other objects in salesforce whenever your creating a any picklist field.

How To Create and How to Use It

1. Goto Setup---->Create---> Click on PickLists


2. Click on New to create a Global PickList


3. Give the Label Name and Description and Click on Save



4. Click on New to add picklist values


5.Enter all picklist values each one in new line


6.After Saving the field looks like below


7.Goto any object and try to create a new Picklist field


8.After clicking on new Select field type as Picklist


9.Here you will get an option to select Global Picklist values as a picklist values for this field.Select the global picklist field that you want to select.The strictly enforce picklist values option is automatically selected.


10. Custom picklist Field detail page looks like below.



Advantage:

        These Global Picklist values will not allow you to enter non picklist field values from the APIs(like Developer Console,Data loader etc..).Example if you define in Global picklist values as New,Open and Close .Whenever your creating a record using APIs if you pass value as In Progress it will not allow because In Progress not available in that picklist field values.

Limitations to Pilot Version

1.For this pilot, the list of inherited values doesn’t appear on the detail page for a picklist that’s based on a global picklist.
2.You can create upto 500 Global picklist fields for organisation



Enjoy...............!!!!!!!!!

Monday, February 15, 2016

Salesforce Interview Questions

1.    Why we go for custom setting instead of normal custom object?

2.    What error will you get in a recurring trigger?

3.    How can you avoid trigger recursion?

4.    What error do we get when a workflow firing another workflow and another and on?

5.    When we need sharing rules?

6.    How many ways can we invoke an apex class?

7.    How many records you can process using data loader?

8.    When do we get system.Timeout exception when inserting records using data loader?

9.    How can you avoid system.Timeout exception when inserting records using data loader error?

10. If any record throws exception while inserting using data loader. What happens to other records?

11. How can you call an custom setting in apex class?

12. How to know which edition your organisation using currently?

13. How to delete the records permanently in salesforce?

14. Can we stop/deactivate the Trigger execution from configuration?

15.  How many APIs are there in Salesforce?

16.    How can you update records using data loader with excel file having records   with one field value=null?

17.    How many types of workflows are there?

18.    Difference between created & every time edited, to meet subsequent criteria?

19.    How many ways you can schedule a batch apex?

20.    Why we go for batch apex?

21.    What methods we have in batch apex?

22.    How to send emails using other than workflows email alert?

23.    How to fire a trigger from a batch class?

24. How many records we can process using batch apex?

25. Can we perform DML operation in a constructor?


How to Implement Trigger Switch in Salesforce

Basic limitation of salesfroce we already know that we can't edit the apex code in Production .Recently we came acroos a situavtion where we need to stop the trigger in Production which is not working as expected.The common way to do this is get the trigger to sandbox and deactivate the same trigger in sandbox and then I have to push that same to prod.

But pushing the apex to PROD involves below things
   1.All the test classes will run we have to make sure that none will fail
   2.Code coverage percentage must be 75% or more

All this process is time consuming process and if the impact of that trigger on your business is critical meanwhile you will be losing more profit.So,The best way to stop the trigger immediately is implementing the trigger switch in your organisation

Trigger Switch :

Trigger switch is nothing but it's way to stop the execution of active trigger using the configuarion stuff.The best configuration feature available in salesforce to stop the trigger that we have to use Custom Setting or Custom Metadata Types.

How to Implement Trigger Switch using Custom Settings

1.Create a List custom setting with name Trigger Switch as shown in below image



2. Create two custom fields Active and Trigger Name on clicking on New in Custom Fields section.


3.Create Active field with data type as "Check Box" as shown in image



4.Create Trigger Name field with data type as "Text" as shown in image

5.Make this Trigger Name field as mandatory by selecting Required checkbox  as shown in image


Now custom setting is ready and I want to activate/deactivate one of the trigger in my org lets assume the trigger name is AccountTrigger from Custom settings without touching the active check box at the trigger level.To control this first we need to create a record for that trigger in Custom Setting.

6. Goto Custom Setting--->Click on Manage and give below details
            
            Name              : Account Trigger
            Trigger Name : AccountTrigger
            Active             : Checked

after saving the record it will looks like below            



7. To activate or to deactivate the trigger from custom settings we need to add the below code snippet at the starting of the trigger.

//Mute Trigger using  Custom Setting 
CustomSettingName switchVar = CustomSettingName.getInstance('TriggerName');
if(switchVar != NULL && 'False'.equalsIgnorecase(String.valueOf(switchVar.isActive__c))){ 
       return;
}

AccountTrigger before adding Switch


trigger AccountTrigger on Account (after update,after insert, before insert, before update) {
   
   //After Update Logic
   if (Trigger.isAfter && Trigger.isUpdate) {
    
        AccountUtility.callAfterUpdate(Trigger.New);
        
   } 
   
   //Before Insert or before Update Logic
    if (Trigger.isBefore &&  (Trigger.isUpdate || Trigger.isInsert) ) {
       AccountUtility.callBeforeUpsert(Trigger.New);
        
    }
    
   //After Insert Logic
   if(trigger.isAfter && trigger.isInsert)
   {  
       AccountUtility.callafterinsert(Trigger.New);
   }
    
}

AccountTrigger After adding Switch


trigger AccountTrigger on Account (after update,after insert, before insert, before update) {
   //Mute Trigger using  Custom Setting 
   TriggerSwitch__c switchVar = TriggerSwitch__c.getInstance('AccountTrigger');
   if(switchVar != NULL && 'False'.equalsIgnorecase(String.valueOf(switchVar.isActive__c)))   { 
           return;
    }
    
   //After Update Logic
   if (Trigger.isAfter && Trigger.isUpdate) {
    
        AccountUtility.callAfterUpdate(Trigger.New);
        
   } 
   
   //Before Insert or before Update Logic
    if (Trigger.isBefore &&  (Trigger.isUpdate || Trigger.isInsert) ) {
       AccountUtility.callBeforeUpsert(Trigger.New);
        
    }
    
   //After Insert Logic
   if(trigger.isAfter && trigger.isInsert)
   {  
       AccountUtility.callafterinsert(Trigger.New);
   }
    
}

How to Activate or Deactivate Trigger


To activate or deactivate the trigger from custom setting first add the trigger switch to each and every trigger in your organisation or to few triggers choice is yours.If you want to activate just go to the particular trigger related record in custom setting and check the active checkbox. to deactivate simply go to the trigger related record and unchecked the active checkbox .

Enjoy....!

Thursday, February 4, 2016

myRule_4_A3 (Action Call) - We can't find an action with the name and action type that you specified

This type error will occurs whenever your performing any deployment activities.This error mainly related to the Process Builder processes or Any Flows that are the part of the deployment package. 

The sample error message looks like below.

Update Oppty-17 Flow Version 0 0 myRule_4_A3 (Action Call) - We can't find an action with the name and action type that you specified.

This error message says that action (Email alert,Field update,task etc) related to this Process Update Oppty-17   is missing as part of the deployment package or not in the targeting instance.

Work Around :

1. Please include that action as part of the deployment package
                                               (or)
2.Make sure that action is available in target instance before your making a deployment

Enjoy....!!

How to Know Which Edition of Salesforce Your Using?

As we already know that there are different types of editions available in salesforce. Based upon the editions that you purchased you will be getting the features of salesforce. To know which editions currently your using we can use below ways to know it very easily.

Approaches

1. Mouse over on any browser tab where salesforce has been open then it will displays edition name which your using as shown below image



2. Write a SOQL query on Organisation object to get the edition name
 


3. Goto the Company information details and there you look for Organisation Edition(Only for Sandbox)


Enjoy........!!!

How to Delete the Records Permanently from the Recycle Bin in Salesforce

Basically in salesforce when you have deleted any record from an object, it will not be deleted permanently and it will be stored in Recycle bin till 15 days from the deletion date.The number of records stored in recycle bin depends on Number of Licenses your organisation has pursed and multiply it with 5000 records.
If the number of records in recycle bin crosses this limit salesforce automatically deletes the old records from Recycle Bin which are at least in recycle bin for 2 hours.If you want to delete the records permanently from recycle bin before salesforce deletes it you can emptyRecylebin() method.


     EmptyRecycleBinResult[] = DataBase.emptyRecyclebin(List of Ids)

Example:

    1. Account Acc = new Account(Id='0016000000I549m');
        Database.emptyRecycleBin(Acc);


Notes:

1. Maximum number of records per call that we can pass is 200
2. Using this function records deleted can not be undeleted again.
3. Theses deleted records from recycle bin can be accessed using the DataBase.queryAll() for some time typically that would be with in 24 hours or may shorter or longer.