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
sp13sp13 

Business Days display

I was able to show Monday to Friday except sunday and saturday. My problem is when the checkbox field 'nightshift__c' is true, the table should only display Monday to Thursday.
here's my code:

public Date getdisplayingdates() {
        listOfDates.clear();
            Date startDate = Date.ValueOf(leave.Leave_Date_From__c);
            Date endDate = Date.ValueOf(leave.Leave_Date_To__c);
            totaldays = startDate.daysBetween(endDate);
            boolean shift = leave.nighshift__c;
            
        if (shift == true) {
            for(integer i=0;i<=totaldays;i++) {
                Date today = startDate;
                Date startOfWeek = today.toStartOfWeek();
                Integer dayOfWeek = today.day()-startOfWeek.day();
    
                if(dayOfWeek == 0 || dayOfWeek == 6 || dayOfWeek == 1) {
                    startDate = startDate.addDays(1);
                } else {
                    listOfDates.add(startDate);
                    startDate = startDate.addDays(1);
            }
            }
        } else {
            for(integer i=0;i<=totaldays;i++) {
                Date today = startDate;
                Date startOfWeek = today.toStartOfWeek();
                Integer dayOfWeek = today.day()-startOfWeek.day();
    
                if(dayOfWeek == 0 || dayOfWeek == 6 || dayOfWeek == 5) {
                    startDate = startDate.addDays(1);
                } else {
                    listOfDates.add(startDate);
                    startDate = startDate.addDays(1);
                }
            }
            
        }
        return startDate;
    }

 

I tried adding 

 || dayOfWeek == 5

when the checkbox is unchecked but it is still displaying Friday.

Any idea what might be the problem?

SF_GuhaSF_Guha

Pls check the rerender condition on the action function. If the particular UI element is not refreshed after unchecking this kinda problem may occur.

sp13sp13

i checked the rerender condition but still having the problem.