Page 1 of 1
Number of rows in 'credit_memo' table
Posted: Mon Aug 25, 2025 11:50 am
by gautam_syncezy
Hi everyone,
I get 940 number of rows in 'credit_memo' table for a client in the database but when I check the front end Simpro I am able to see 4000+ records under 'Credit'. Can anybody guide what could be a possible reason behind this difference?
Re: Number of rows in 'credit_memo' table
Posted: Tue Aug 26, 2025 1:24 pm
by mlt
Hi Gautam,
This is a very common issue when first working with the Simpro API, and you're on the right track. The discrepancy you're seeing is due to API pagination.
By default, most Simpro API endpoints will only return a set number of records per request (usually 250, but it can vary). To retrieve all 4000+ records, you need to make repeated calls to the API, incrementing the page parameter each time until you receive an empty response.
Here's a simple pseudo-code example of how you can loop through the pages to get all the credit memos:
Code: Select all
// Pseudo-code for fetching all credit memos
all_credit_memos = []
current_page = 1
keep_fetching = true
while (keep_fetching) {
// Construct the API URL with the current page number
api_url = "https://{your_build}.simprosuite.com/api/v1.0/companies/0/creditNotes/?page=" + current_page
// Make the GET request
response = GET(api_url)
if (response is not empty) {
// Add the records from this page to your master list
add response to all_credit_memos
// Increment the page for the next loop
current_page = current_page + 1
} else {
// The response was empty, indicating we've fetched all pages
keep_fetching = false
}
}
// At this point, the 'all_credit_memos' array will contain all 4000+ records.
// You can now check the count of this array.
By implementing a loop like this, you'll be able to pull the complete dataset that you see in the front end. This pagination logic applies to almost all list-based endpoints in the Simpro API (jobs, customers, invoices, etc.).
Hope that clears things up!