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