Skip to content

Keep Suggestions

Step 6 of 6

Overview

In the Schedule Sessions Copilot, the "Keep Suggestions" functionality is crucial for finalizing the AI-generated session schedules. This process involves transferring the proposed session scheduling details from the temporary records to the main sessions table in Business Central. This step is the last phase where user-generated schedules are confirmed and saved into the system.

Implementation Steps

1. Apply Suggestions

Navigate to "src\4-ScheduleSessionsCopilot\PromptDialog\CopScheduleSessions.Page.al" and implement a procedure to apply the session schedule. This procedure retrieves the proposed session details from the "GPT Cop. Schedule Sessions Sub" part and calls another procedure to apply these details to the session database.

Note

  • Ensure the procedure retrieves records based on the current generation ID, which represents the confirmed user interactions with the copilot.
  • Save the session schedule proposals to the main session table in Business Central.

2. Define Retrieval

In "src\4-ScheduleSessionsCopilot\PromptDialog\CopScheduleSessionsSub.Page.al", define a procedure GetRecords to retrieve session proposals for a given generation ID. This procedure is similar to a Load function but in reverse, where it collects data from the temporary table filtered by generation ID and prepares it for application.

Note

Set a filter on the Generation Id to ensure only relevant records are processed.

3. Save Sessions

Go to "src\4-ScheduleSessionsCopilot\Implementation\ScheduleSessionsImpl.Codeunit.al" and implement the Apply procedure. This method takes the session proposals and updates the main sessions table with the new schedule details.

Detailed Steps:

  • Loop through each proposed session detail.
  • For each session, update the main session record with the new scheduling details such as date, track number, start time, and end time.
  • Mark the session as scheduled to reflect the update in the system.
    procedure Apply(var SessionScheduleProposal: Record "GPT Cop. Schedule Session")
    begin
        if SessionScheduleProposal.FindSet() then
            repeat
                ScheduleSession(SessionScheduleProposal);
            until SessionScheduleProposal.Next() = 0;
    end;

    local procedure ScheduleSession(SessionScheduleProposal: Record "GPT Cop. Schedule Session")
    var
        Session: Record "GPT Session";
    begin
        if not Session.Get(SessionScheduleProposal."Session Code") then
            exit;

        Session."Date" := SessionScheduleProposal."Session Date";
        Session."Track No." := SessionScheduleProposal."Track No.";
        Session."Start Time" := SessionScheduleProposal."Session Start Time";
        Session."End Time" := SessionScheduleProposal."Session End Time";
        Session.Status := Session.Status::Scheduled;
        Session.Modify();
    end;

4. Conclusion

By completing these steps, you have implemented a last required step in your Schedule Sessions Copilot to allow users to review AI-generated suggestions and commit them to the database, effectively scheduling sessions based on AI recommendations.

🎇 Congratulations!

You've successfully implemented your Schedule Sessions Copilot to assist users in efficiently planning and organizing event schedules, leveraging AI to optimize session timings within Business Central.