You need to sign in to do that
Don't have an account?

Trigger Apex Class before upfate
I want to create test class for this trigger:
trigger TriggerApprovalCommentOpp on Opportunity (before update) {
if(trigger.isUpdate){
List<Opportunity> opptyList = [Select id,
(Select Id,
IsPending,
ProcessInstanceId,
TargetObjectId,
StepStatus,
OriginalActorId,
ActorId,
RemindersSent,
Comments,
IsDeleted,
CreatedDate,
CreatedById,
SystemModstamp
FROM ProcessSteps
ORDER BY CreatedDate DESC)
From opportunity
WHERE Id IN : Trigger.new];
if(opptyList.size() > 0){
for(Opportunity opp : opptyList){
for(Opportunity opp1 : Trigger.new) {
//check copy comment is true
if(opp.id == opp1.id && opp1.CopierCommentaires__c) {
if (opp.ProcessSteps.size() > 0) {
opp1.Drniercommentairedapprobation__c = opp.ProcessSteps[1].Comments;
opp1.CopierCommentaires__c = false;
}
}
}
}
}
}
}
Can you help me.
trigger TriggerApprovalCommentOpp on Opportunity (before update) {
if(trigger.isUpdate){
List<Opportunity> opptyList = [Select id,
(Select Id,
IsPending,
ProcessInstanceId,
TargetObjectId,
StepStatus,
OriginalActorId,
ActorId,
RemindersSent,
Comments,
IsDeleted,
CreatedDate,
CreatedById,
SystemModstamp
FROM ProcessSteps
ORDER BY CreatedDate DESC)
From opportunity
WHERE Id IN : Trigger.new];
if(opptyList.size() > 0){
for(Opportunity opp : opptyList){
for(Opportunity opp1 : Trigger.new) {
//check copy comment is true
if(opp.id == opp1.id && opp1.CopierCommentaires__c) {
if (opp.ProcessSteps.size() > 0) {
opp1.Drniercommentairedapprobation__c = opp.ProcessSteps[1].Comments;
opp1.CopierCommentaires__c = false;
}
}
}
}
}
}
}
Can you help me.
Create couple of opportunities and make sure that CopierCommentaires__c is FALSE and add process steps to only few opportunities and then update opp making CopierCommentaires__c to TRUE. Finally verify that CopierCommentaires__c is False using system.assert.
Hope this helps...!!