Discussions

Expand all | Collapse all

Is there a way to use API_GetNumRecords to count only related records?

  • 1.  Is there a way to use API_GetNumRecords to count only related records?

    Posted 04-10-2018 14:59
    Is there a way to use API_GetNumRecords to count only related records?


  • 2.  RE: Is there a way to use API_GetNumRecords to count only related records?

    Top
    Contributor
    Posted 04-10-2018 17:12
    HI Chad,

    If you are looking to run an API call to return a count of records that meet a specific criteria, for example if you are looking only for records that have a value in their related parent field or that have a number of child records summarized up you would most likely want to use API_DoQueryCount.

    Lets say you were looking at a table that lists your Companies and you want to only show the number of Companies that have a contact. You would summarize up the number of Contacts related to each company and set up your query to only return the number of records where that summary field is great then 1. Alternatively, you could do the same by saying in your child table of Contacts only return a count of the Contact records that have a value in Related Company. You can find the basics of API_DoQueryCount on our API Guide:

    https://help.quickbase.com/api-guide/index.html#do_query_count.html

    Is this the sort of functionality you were looking for Chad? I hope this information was helpful. 


  • 3.  RE: Is there a way to use API_GetNumRecords to count only related records?

    Posted 04-10-2018 19:40
    kind of.

    How would you use DoQueryCount to return only the count of child records related to a parent record?

    example:

    Parent Record 1 has 5 child records
    Parent Record 2 has 7 child records
    etc.


  • 4.  RE: Is there a way to use API_GetNumRecords to count only related records?

    Top
    Contributor
    Posted 04-11-2018 19:31
    A DoQueryCount wouldn't count records quite like that, it is instead set to count records that meet the nature of a query. For that format you might instead want to look at just DoQuery. It allows you to put in a query string and dictate how you want it to be returned. Specifically you can use the section on clist to dictate how you want that information to be returned. In it you could ask for the Parent Record to be displayed as the most useful fields to help you identify them and the # of related child records field.

    For example if you had a Companies table and Contacts as their child records you could set it up to return the Record ID field, Company name field, and # of Related Contacts field as the result with a query to only show records that have Related Contacts. So you would get something like

    7, Paper Co., 5

    To say that Company 7, Paper Co., has 5 Related Contacts. That syntax is covered in the entry for DoQuery. 

    https://help.quickbase.com/api-guide/index.html#do_query.html

    Alternatively you can create a report in Quick Base that does much the same thing if you are just looking to get this type of information. The you can even set that report to email out on a schedule to specific users in the application. If you aren't needing just an API call.