Triggers
1.What is an workflow?
A:Workflow Rules are automated process to send E-mails alerts,
assign tasks, update fields on trigger criteria based requirements.
2.When will the Workflows invoke?
A: Workflows are invoked
When ever the given W/F criteria is met during the DML operations(Insert (or) update) on particular object
3. What is a trigger?
A:Triggers are the automated actions when ever any DML operation is performed on particular object
4.What are the differences between Workflow and triggers?
A:
Triggers Workflows
1. You can perform all DML operatios 1. You can perform only update operation, you cannot perform insert ,
(insert,update,delete,undelete) delete and undelete operations
2. You can perform any logic on any 2.You can perform update operation on
object in entire organization only that particular object and corresponding child object
5.What are the Triggers Events?
A: There are seven trigger events ,this events will specify when the trigger has to be fired
1.Before insert
2.Before update
3.Before delete
4.After insert
5.After update
6.After delete
7.After undelete
6. What are the Trigger Context varibles?
A: These are the varibles where the data will stored in triggers
1.Trigger.New
2.Trigger.Old
3.Trigger.NewMap
4.Trigger.OldMap
5.Trigger.isBefore
6.Trigger.isAfter
7.Trigger.isInsert
8.Trigger.isUpdate
9.Trigger.isdelete
10.Trigger.isundelete
7.If we insert 100 records how many times will Trigger fire?
A:The Trigger will fire only once but the logic written in the trigger will run 100 times (i.e, on each record once)
8.What is bulk Trigger?
A:All triggers are bulk triggers by default, and can process multiple records at a time.
You should always plan on processing more than one record at a time.
An Event object that is defined as recurring is not processed in bulk for insert, delete, or update triggers.
9.What is the difference between Trigger.New and Trigger.Old in update Triggers?
A: Before Update
Trigger.New:- It contais the records which you are going to update with the modified values
We can perform Read and Write operation
Trigger.Old:- It contais the recors which you are going to modify with their old values
we can perform read and SOQL
After Update
Trigger.New:- It contais the records which you are going to update with the modified values
We can perform Read ,SOQL and DML
Trigger.Old:- It contais the recors which you are going to modify with their old values
we can perform only read operation
10.What is the difference between Trigger.New and Trigger.NewMap in update Triggers?
A: Trigger.New:-It contais the records which you are going to update with the modified values
Trigger.NewMap:-It contais Map<Id,Sobject> where "ID" of the records as key and records as "VALUE";
11.When you can perform operation using Before Trigger and After Trigger which one you prefer?
A: Before Trigger.
Because if we want to perform any modifications on dats in after Trigger we have to perform DML operations on data
where as in Before trigger we can perform write operation on data(Bcz data is not yet stored) which will not considere as DML .
12.Can we write SOQL query to fetch the data in Trigger.New in BeforeTrigger?
A: NO, we cannot write SOQL query on Trigger.New in Before Triggers because the data is not yet saved to Sobject.
NOTE:-we will write SOQL queries to fetch the data was stored in Sobject.
13.Can we write DML on List of records which are in Trigger.New in BeforeTrigger?
A: NO, we cannot write DML operations on records which are Trigger.New because the data is not yet saved to Sobject.
NOTE:-we can only write DML operations on those records which were saved in Sobject.
14.What are Resursive triggers?
A:If any trigger calls itself then such triggers are called Recursive Triggers.
15. How to handle Recursive triggers?
A:We can handle these recursive Triggers using "Static Boolean".
Example:
public class TriggerHandler{
public Static Boolean flag=true;
public Static void show(){
if(flag==true){
flag=false;
Account a = new Account(Name='sameer');
insert a;
}
}
}
A:Workflow Rules are automated process to send E-mails alerts,
assign tasks, update fields on trigger criteria based requirements.
2.When will the Workflows invoke?
A: Workflows are invoked
When ever the given W/F criteria is met during the DML operations(Insert (or) update) on particular object
3. What is a trigger?
A:Triggers are the automated actions when ever any DML operation is performed on particular object
4.What are the differences between Workflow and triggers?
A:
Triggers Workflows
1. You can perform all DML operatios 1. You can perform only update operation, you cannot perform insert ,
(insert,update,delete,undelete) delete and undelete operations
2. You can perform any logic on any 2.You can perform update operation on
object in entire organization only that particular object and corresponding child object
5.What are the Triggers Events?
A: There are seven trigger events ,this events will specify when the trigger has to be fired
1.Before insert
2.Before update
3.Before delete
4.After insert
5.After update
6.After delete
7.After undelete
6. What are the Trigger Context varibles?
A: These are the varibles where the data will stored in triggers
1.Trigger.New
2.Trigger.Old
3.Trigger.NewMap
4.Trigger.OldMap
5.Trigger.isBefore
6.Trigger.isAfter
7.Trigger.isInsert
8.Trigger.isUpdate
9.Trigger.isdelete
10.Trigger.isundelete
7.If we insert 100 records how many times will Trigger fire?
A:The Trigger will fire only once but the logic written in the trigger will run 100 times (i.e, on each record once)
8.What is bulk Trigger?
A:All triggers are bulk triggers by default, and can process multiple records at a time.
You should always plan on processing more than one record at a time.
An Event object that is defined as recurring is not processed in bulk for insert, delete, or update triggers.
9.What is the difference between Trigger.New and Trigger.Old in update Triggers?
A: Before Update
Trigger.New:- It contais the records which you are going to update with the modified values
We can perform Read and Write operation
Trigger.Old:- It contais the recors which you are going to modify with their old values
we can perform read and SOQL
After Update
Trigger.New:- It contais the records which you are going to update with the modified values
We can perform Read ,SOQL and DML
Trigger.Old:- It contais the recors which you are going to modify with their old values
we can perform only read operation
10.What is the difference between Trigger.New and Trigger.NewMap in update Triggers?
A: Trigger.New:-It contais the records which you are going to update with the modified values
Trigger.NewMap:-It contais Map<Id,Sobject> where "ID" of the records as key and records as "VALUE";
11.When you can perform operation using Before Trigger and After Trigger which one you prefer?
A: Before Trigger.
Because if we want to perform any modifications on dats in after Trigger we have to perform DML operations on data
where as in Before trigger we can perform write operation on data(Bcz data is not yet stored) which will not considere as DML .
12.Can we write SOQL query to fetch the data in Trigger.New in BeforeTrigger?
A: NO, we cannot write SOQL query on Trigger.New in Before Triggers because the data is not yet saved to Sobject.
NOTE:-we will write SOQL queries to fetch the data was stored in Sobject.
13.Can we write DML on List of records which are in Trigger.New in BeforeTrigger?
A: NO, we cannot write DML operations on records which are Trigger.New because the data is not yet saved to Sobject.
NOTE:-we can only write DML operations on those records which were saved in Sobject.
14.What are Resursive triggers?
A:If any trigger calls itself then such triggers are called Recursive Triggers.
15. How to handle Recursive triggers?
A:We can handle these recursive Triggers using "Static Boolean".
Example:
public class TriggerHandler{
public Static Boolean flag=true;
public Static void show(){
if(flag==true){
flag=false;
Account a = new Account(Name='sameer');
insert a;
}
}
}
Comments
Post a Comment