Skip to main content
deleted 67 characters in body
Source Link

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.

See See addError usage here:

Usage

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

However, I think the real problem is in this line:

evExist.StartDateTime,evWrapper.startDateTime) < checkForMinimumEndDate(evExist.EndDateTime,evWrapper.endDateTime) ) 

You are comparing events from your query evExist which returns results for both owners with ones in evdatetimeMapper which is only for a single owner, as a result you are comparing 1 event of owner A in trigger context A (evWrapper) with evExist which can be either this same event or the event submitted by user B. This boolean passes because the two events have different owners and you never meant to compare them.

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.

See addError usage here:

Usage

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

However, I think the real problem is in this line:

evExist.StartDateTime,evWrapper.startDateTime) < checkForMinimumEndDate(evExist.EndDateTime,evWrapper.endDateTime) ) 

You are comparing events from your query evExist which returns results for both owners with ones in evdatetimeMapper which is only for a single owner, as a result you are comparing 1 event of owner A in trigger context A (evWrapper) with evExist which can be either this same event or the event submitted by user B. This boolean passes because the two events have different owners and you never meant to compare them.

You need to handle this logic before insert. See addError usage here:

Usage

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

However, I think the real problem is in this line:

evExist.StartDateTime,evWrapper.startDateTime) < checkForMinimumEndDate(evExist.EndDateTime,evWrapper.endDateTime) ) 

You are comparing events from your query evExist which returns results for both owners with ones in evdatetimeMapper which is only for a single owner, as a result you are comparing 1 event of owner A in trigger context A (evWrapper) with evExist which can be either this same event or the event submitted by user B. This boolean passes because the two events have different owners and you never meant to compare them.

added 652 characters in body
Source Link

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.

See addError usage here:

Usage

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

However, I think the real problem is in this line:

evExist.StartDateTime,evWrapper.startDateTime) < checkForMinimumEndDate(evExist.EndDateTime,evWrapper.endDateTime) ) 

You are comparing events from your query evExist which returns results for both owners with ones in evdatetimeMapper which is only for a single owner, as a result you are comparing 1 event of owner A in trigger context A (evWrapper) with evExist which can be either this same event or the event submitted by user B. This boolean passes because the two events have different owners and you never meant to compare them.

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.

See addError usage here:

Usage

When used on Trigger.new in before insert and before update triggers, and on Trigger.old in before delete triggers, the error message is displayed in the application interface.

However, I think the real problem is in this line:

evExist.StartDateTime,evWrapper.startDateTime) < checkForMinimumEndDate(evExist.EndDateTime,evWrapper.endDateTime) ) 

You are comparing events from your query evExist which returns results for both owners with ones in evdatetimeMapper which is only for a single owner, as a result you are comparing 1 event of owner A in trigger context A (evWrapper) with evExist which can be either this same event or the event submitted by user B. This boolean passes because the two events have different owners and you never meant to compare them.

Source Link

You need to handle this logic before insert. Adderror won't rollback the records for you in an after context.