Tuesday, February 14, 2017

How to query data which was modified in specific time limit in Salesforce?


Below is the SOQL to query data which was modified between 1 PM and 5 PM.

Sample SOQL:

SELECT Id, LastModifiedDate FROM Account WHERE LastModifiedDate = TODAY AND HOUR_IN_DAY(LastModifiedDate) >= 13 AND HOUR_IN_DAY(LastModifiedDate) < 17

How to get records which are modified in last 7 days in Salesforce?

Check the below SOQL to get records which are modified in last 7 days.

Sample SOQL:

SELECT Name, Id, LastModifiedDate FROM Account WHERE LastModifiedDate = LAST_N_DAYS:7

What is granular locking in Salesforce?

By default, the Force.com platform locks the entire group membership table to protect data integrity when Salesforce makes changes to roles and groups. This locking makes it impossible to process group changes in multiple threads to increase throughput on updates. When the granular locking feature is enabled, the system employs additional logic to allow multiple updates to proceed simultaneously if there is no hierarchical or other relationship between the roles or groups involved in the updates.

Below links provide more details on this.

https://resources.docs.salesforce.com/sfdc/pdf/draes.pdf

How to check object level security within a Visualforce page in Salesforce?

{!$ObjectType.Account.Accessible} is used to check object level security within a Visualforce page in Salesforce

Visualforce Code:


<apex:page>
    {!$ObjectType. Account.Accessible} 
</apex:page>

Tuesday, January 31, 2017

Which interface needs to be implemented in Apex to be used in Flow ?

We can execute apex as well using flow by annotating it with “@InvocableMethod” and marking method as static. However this method only takes one parameter of type list. If we want to send multiple parameters, then simplest way is to create comma separated list of argument and pass it. In this method, we can break it and use according. Below is sample code.
Global class Flow_UpdateAccountField {    
    @InvocableMethod
    public static void performUpdate(List<String> lstCSV){
        List<String> recIds = lstCSV[0].split(',');
        //0 - AccId, 1-field1__c
  Account acc = new Account(Id=recIds[0], field1__c=recIds[1]);
  update acc;        
    } 

}