function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lakshya agrawallakshya agrawal 

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?
Ajay Patel 54Ajay Patel 54

Yes seem good  you have followed teh rules