The Related Records field in kintone is a useful field that lists other records that match a given condition. The Related Records field though does not state how many records it is listing - which may become hard to count manually when there are many records listed.
This sample code does the counting for you, and displays the number in a Space field of your App.
As shown in the image below, each record will display a different number for the total number of related records.
Refer to the Tutorial page, on how to add scripts to your app.
This sample will only display the number - it will not store and save the total number in a field.
This sample does not take into account of the "filter" option of the Related Records field.