Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (13.1k points)
I want to create a list in Salesforce which will hold appointments, like for today's appointment it should show the record. Can anyone help me how I can able to do that using VF Page?

1 Answer

0 votes
by (26.7k points)

You can take the below code as a reference:

class CTimeSlot

{

    public Time           tStart         {get; set;}

    public Appointment__c sAppointment   {get; set;}

    public CTimeSlot(Time startTime)

    {

        tStart = startTime;

        Appointment__c = null;

    }

}

// ** snip ** 

list<CTimeSlot> liTimeSlots = new list<CTimeSlot>();

// ** snip ** loop through times, and for each add an entry to the list

    CTimeSlot newSlot = new CTimeSlot(loopTime);

    liTimeSlots.add(newSlot);

    mapTimeToSlot.put(loopTime + '', newSlot);

}

// ** snip ** when running through your query results of Appointment__c objects:

for(Appointment__c sAppointment : [select Id, Time__c from Appointment__c where ...])

{

    if(mapTimeToSlot.get(sAppointment.Time__c) != null)

    {

        mapTimeToSlot.get(sAppointment.Time__c).sAppointment = sAppointment;

    }

}

This will consist of class and a list of objects, which will help you to get idea.

I hope this will help.

Want to become a Salesforce expert? join Salesforce Integration Training now!!

Want to know more about Salesforce Integration? Watch this video on Salesforce Integration Tutorial | Salesforce Online Training :

Browse Categories

...