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
Sanchivan SivadasanSanchivan Sivadasan 

How do you prevent Shift Time overlap?

Hi All,

I have an object called ShiftConfig with the following:
StartTime
EndTime
Enabled__c
Sunday__c
Monday__c
Tuesday__c
Wednesday__c
Thursday__c
Friday__c
Saturday__c

So for each weekday we can have multiple shifts. For an example, we can have the following:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1200         -   1800
Shift3: 1800         -   0600

We need a validation so the times do not overlap. So we need to prevent something like this:

Tuesday:
            StartTime   EndTime
Shift1: 0600         -   1200
Shift2: 1100         -   1800
Shift3: 1500         -   0600

How can I do this in a trigger?

Thanks.

Sanch.
Sonam_SFDCSonam_SFDC
So I understand you will be capturing each day's shift slot through this object..right? 

Let's say 10th March will have 3 records : Shift1: 0600         -   1200
Shift2: 1200         -   1800
Shift3: 1800         -   0600

Could you please give a sample of how you wish to log the records in this object

if we go by the date saying single date have 3 shift config records - we can then create a trigger to compare the start and end time entered with the ones existing for that particular date and so avoid overlaps.

I'm hoping I got your requirement correctly, if not - pls elaborate..
Sanchivan SivadasanSanchivan Sivadasan
Here is a screen shot of how the data will look:
 User-added image