Monday 17 September 2018

Unable to find process builder processes in change set :


You need to select Flow Definition in Component Type. Also you need to activate process builder in production after deployment.



Thursday 13 September 2018

                             Queueable Apex:


Queueable Apex is similar to future methods, but provide additional job chaining and allow more complex data types to be used.

Queueable Apex allows you to submit jobs for asynchronous processing similar to future methods with the following additional benefits:
  • Non-primitive types: Your Queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types. Those objects can be accessed when the job executes.
  • Monitoring: When you submit your job by invoking the System.enqueueJob method, the method returns the ID of the AsyncApexJob record. You can use this ID to identify your job and monitor its progress, either through the Salesforce user interface in the Apex Jobs page, or programmatically by querying your record from AsyncApexJob.
  • Chaining jobs: You can chain one job to another job by starting a second job from a running job. Chaining jobs is useful if you need to do some sequential processing.
---------------------------------------------------------------------------------------------------------------------
Queueable Apex:

public class QueueableExample implements Queueable {
public void execute(QueueableContext context) {
        Account a = new Account(Name='Annappa',Phone='11111111');
       insert a;     
    }
}
----------------------------------------------------------------------------------------------------------------------
Execute:

ID jobID = System.enqueueJob(new QueueableExample());
system.debug(jobId);

-------------------------------------------------------------------------------------------------------------------------

Eliminate bad code coverage data for Apex classes:


Issue: There may be times where we see a different code coverage value than the actual value. This might be caused due to bad code coverage data or aggregate results from previous test runs.

Solution: To eliminate any bad code coverage data in your organization you can follow the steps mentioned below.

For Classic:
---------------------------------------------------------------------------------
First re-run all tests in your organization: 
---------------------------------------------------------------------------------
1a) Setup | Develop | Apex Test Execution
  b) View Test History
  c) Clear test data.

2 a) Setup | Develop | Apex Classes
  b) Compile all classes

3 a) Setup | Develop | Apex Test Execution
 b) Select tests | "My Namespace" | Select all
 c) Click run

4 a) Setup | Develop | Apex Classes
  b) Estimate your organization's code coverage

  ---------------------------------------------------------------------------------
To Remove Bad data:
---------------------------------------------------------------------------------
1 a) Open Developer console
  b) Execute the following query in "Query Editor" with "Tooling API" checked.

SELECT Id, NumLinesUncovered FROM ApexCodeCoverageAggregate WHERE NumLinesUncovered = NULL

c) Select all the returned rows and hit "Delete Row"
d) Try to estimate the code coverage again
---------------------------------------------------------------------------------

                        Error while updating debug log trace flag


Some times we will receive below error while setting  debug log trace flag for user

"Having an active trace flag triggers debug logging. You have 259 MB of the maximum 250 MB of debug logs. Before you can edit trace flags, delete some debug logs."

Solution:

  • In dev console, Select tab "Query Editor" at the bottom of the console
  • Select check box "Use Tooling API"
  • Use this query: SELECT Id FROM ApexLog
  • Delete all rows

Once all rows are deleted you will be able to save new debug logs.

Monday 3 September 2018

Replacing the Picklist old values into new values


Suppose we have a picklist (Test) which contains A,B,C values. For example A belongs to 100 records,B belongs to 200 records and C belongs to 300 records respectively.

Picklist Name: Test

A---- 100
B-----200
C-----300

Now we have new requirement: Instead of "A",we need to update with "D".This means all 100 records belongs to "A" replace with "D"



How to do it?

Using "Replace" option we can do it




Will the updated record fire Apex Triggers, Workflow Rules, etc.?

workflow rules, triggers, validation rules, flows, Process Builders, and any other logic that would run on a normal DML operation will not run as a result of using Replace.

Dynamically Determine Calling Context:

In some cases we need to Identify the calling context  whether its called from trigger,batch,future methods  etc..

These are the steps to determine it:

Batch - System.isBatch()
@future - System.isFuture()
Queueable - System.isQueueable()
Schedulable - System.isScheduled()
Trigger - Trigger.isExecuting

For example:
Consider  batch class Example:
if(System.IsBatch() == true){
    //Its calling from batch
}

More Information:

https://salesforce.stackexchange.com/questions/131140/dynamically-determine-calling-context