You need to sign in to do that
Don't have an account?
Andrew Hoban 14
Trigger if a date from a date field has been selected three times
Hi all,
I am creating a trgger that will fire an error when a particular picklist value has been selected three times. This works and the error message displays.
I now need the error to display if a date from a date field has been selected three times.
I am unsure how i would implement this inside my trigger.
Any help would be appreciated. Thanks.
Trigger:
I am creating a trgger that will fire an error when a particular picklist value has been selected three times. This works and the error message displays.
I now need the error to display if a date from a date field has been selected three times.
I am unsure how i would implement this inside my trigger.
Any help would be appreciated. Thanks.
Trigger:
trigger SevenAsideQuantityTrigger on Opportunity (before insert,before update) { Integer count =[select count() from Opportunity WHERE Select_Area__c='7-a-side Pitch' AND Start_Time__c!=null]; for(Opportunity a:trigger.new){ if(count==2&&a.Select_Area__c=='7-a-side Pitch'&& a.Start_Time__c=='09:00'){ a.addError('7-a-side Pitch is fully booked at this time.'); } if(count==2&&a.Select_Area__c=='7-a-side Pitch'&& a.Start_Time__c=='10:00'){ a.addError('7-a-side Pitch is fully booked at this time.'); } if(count==2&&a.Select_Area__c=='7-a-side Pitch'&& a.Start_Time__c=='11:00'){ a.addError('7-a-side Pitch is fully booked at this time.'); } if(count==2&&a.Select_Area__c=='7-a-side Pitch'&& a.Start_Time__c=='12:00'){ a.addError('7-a-side Pitch is fully booked at this time.'); } } }
Hi Andrew,
Are you trying to check the date field value with other 2 date field in the record. If yes then
1: As you are iterating the Opportunity records.
2: get that specific data value store it into variable.
3: then compare this with those 2 data value.
4: it satisfied use a.addError();
Regards
MCS
Thanks