Friday 26 July 2019

          Cache control value control in a static resource:


Private- It specifies static resource data cached on the Salesforce server shouldn’t be shared with other users. The static resource is only stored in cache for the current user’s session.

Public specifies that the static resource data cached on the Salesforce server be shared with other users in your organization for faster load times.

https://salesforce.stackexchange.com/questions/9038/what-does-the-cache-control-value-control-in-a-static-resource

           System.ListException: List index out of bounds error

Before referring to the 0th index of list you must perform a check on whether the list is empty or not. Whenever you try to access records from list first check if its empty or not.

List <contact>contactList = [Select Id, Name from contact Limit 10];
// Before processing the list check if its empty or not
// It will go inside the loop only if the List is having values in it.
if(contactList.size() > 0) {
 // Do something with contactList [0].Name
 }
// If you try to access contactList [0] without empty check then it will obviously throw that error!!


Saturday 20 July 2019

Can we write SOSL statements in triggers


Yes, we can write SOSL inside triggers.There is no such restriction.

Code:

trigger trg_AccountSOSL on Account (before insert, before update) {

List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];
List<account> myAcc = ((List<Account>)searchList[0]);

system.debug(myAcc[0].name);
}


UNABLE_TO_LOCK_ROW unable to obtain exclusive access to this record or 1 records


Solution:

When you have multiple jobs running that update the same set of records, it's recommended to lock the records using the FOR UPDATE keyword. 

It will ensure that the record is locked and no other job can update the same record at that point in time. The conflicting job will then wait until the locking on the record is released and then perform the required operation. 

This will avoid conflicts between jobs that are running concurrently and will not throw up this exception. 


You can refer the below link to learn more about record locking.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_locking_statements.htm

Thursday 11 July 2019

                                   Organization Administration Locked…?
we will face the above error Message.while saving the classes(sometimes)
This usually means:
  1. Something is being deployed via API (check Setup -> Monitor Deployments)
  2. Something is being deployed via change sets (Setup -> Deploy -> Inbound change sets)
  3. You're running some unit tests