Skip to content

589 enhance appointment limits #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

DavidCuentasMar
Copy link
Contributor

@DavidCuentasMar DavidCuentasMar commented Mar 21, 2025

Critical Changes

  • 2 New fields:
    • Enforce_Registrations_Limit__c (Checkbox, Default Unchecked)
    • Appointment_Registrations_Limit__c (Number, Default 9999)
  • Access to new fields has been added to the Summit_Events_Registrant permission set

Changes

  • Use of AggregateResult in SummitEventsRegisterAppointmentCtlr
  • SummitEventsRegisterAppointmentCtlr class removes appointments before rendering them if:
    • Related Summit_Events_Appointments__c has Enforce_Registrations_Limit__c equals to true
    • AND
    • Related registrations are >= Appointment_Registrations_Limit__c
  • New fields added to Summit Events Appointment Default Layout
  • SummitEventsRegisterAppointment_TEST edited to consider this new scenario

Issues Closed

@FrancisTR FrancisTR requested a review from tcdahlberg March 21, 2025 02:47
@FrancisTR FrancisTR added the enhancement New feature or request label Mar 21, 2025
@tcdahlberg
Copy link
Contributor

tcdahlberg commented May 19, 2025

@DavidCuentasMar , I think we have to count the appointment type limits by instance rather than event. I tried to modify your inner query a bit to account for instance:

(SELECT Id FROM UG_Visit_Appointments__r WHERE Event_Registration__r.Event_Instance__c = :eventInformation.instanceId)

I was getting some errors with this approach. Then I wondered if we should just write an AggregatedResults query to count and then apply to a map of appointment types and the count for your comparison method later. Here is a quick example of what I mean.

AggregateResult[] eventAppointmentCounts = [
        SELECT COUNT(Id) aCount, Event_Appointment_Type__c
        FROM Summit_Events_Appointments__c
        WHERE Event_Registration__r.Event_Instance__c = 'a06E200000MTeaIIAT'
        AND Event_Appointment_Type__r.Enforce_Registrations_Limit__c = TRUE
        GROUP BY Event_Appointment_Type__c
];

Map<Id, Integer> appointmentTypeIdMapToCount = new Map<Id, Integer>();
for (AggregateResult ar : eventAppointmentCounts) {
    appointmentTypeIdMapToCount.put((Id) ar.get('Event_Appointment_Type__c'), (Integer) ar.get('aCount'));
}

What do you think?

I also added the new fields you created to the admin permission set.

Thanks!

@DavidCuentasMar
Copy link
Contributor Author

Hi @tcdahlberg you are completely right on counting by instance instead of event. That scenario didn't cross my mind 😅 Thanks!

I'm coming back from a long vacation, I'll try get up to speed asap 👍

@DavidCuentasMar
Copy link
Contributor Author

@tcdahlberg New changes applied. I used AggregateResult suggestion 👍
Let me know how they look. I also modified a test class to consider that scenario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants