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

trigger question??
Trigger OpportuniytTrigger On Opportunity(before update){
OpportuniytTriggerHandler.checkProduct(trigger.new);
}
public class OpportuniytTriggerHandler {
public static void checkProduct(List<Opportunity> newRecords) {
List<Id> oppIds = new List<Id>();
for(Opportunity opp : newRecords)
{
if(opp.StageName == 'Start' || opp.StageName == 'No Start' || opp.StageName == 'Delayed Start' || opp.StageName == 'Established Patien' || opp.StageName == 'Re-act')
{
oppIds.add(opp.Id);
}
}
if(oppIds.size() > 0)
{
List<OpportunityLineItem> oppProduct = [SELECT Id, Name FROM OpportunityLineItem WHERE OpportunityId IN : oppIds];
if(oppProduct.size() == 0 )
{
newRecords[0].addError('Please select product to select the given StageName.');
}
}
}
}
is this trigger bulkified?
OpportuniytTriggerHandler.checkProduct(trigger.new);
}
public class OpportuniytTriggerHandler {
public static void checkProduct(List<Opportunity> newRecords) {
List<Id> oppIds = new List<Id>();
for(Opportunity opp : newRecords)
{
if(opp.StageName == 'Start' || opp.StageName == 'No Start' || opp.StageName == 'Delayed Start' || opp.StageName == 'Established Patien' || opp.StageName == 'Re-act')
{
oppIds.add(opp.Id);
}
}
if(oppIds.size() > 0)
{
List<OpportunityLineItem> oppProduct = [SELECT Id, Name FROM OpportunityLineItem WHERE OpportunityId IN : oppIds];
if(oppProduct.size() == 0 )
{
newRecords[0].addError('Please select product to select the given StageName.');
}
}
}
}
is this trigger bulkified?
Yes seem good you have followed teh rules