Pagination

Methods that return a collection will include a pagination attribute which can be used to retrieve the next page of results (if available).

try {    
    CalendlyApi.OrganizationMembershipQueryParams params = new CalendlyApi.OrganizationMembershipQueryParams();
    CalendlyApi.OrganizationMembershipCollection result = organization.getOrganizationMemberships(params);
    
    List<CalendlyApi.OrganizationMembership> memberships = new List<CalendlyApi.OrganizationMembership>();
    memberships.addAll(result.collection);
    
    Boolean hasNextPage = result.pagination.hasNextPage();
    
    while (hasNextPage) {
    	result = result.pagination.nextPage();
        memberships.addAll(result.collection);
        hasNextPage = result.pagination.hasNextPage();
    }
    
    System.debug('Memberships: ' + memberships);
} catch (CalendlyApi.CalendlyApiException e) {
    System.debug('Error');
    System.debug(e.message);
    System.debug(e.title);
}

Last updated

Was this helpful?