Why use a script at all?
Surely the Company and Query tables are linked by CompanyID?
A List view layout based on Company can show the total related records in Query using either a calculation field that uses the count function or you can place a "count of" summary field from Query on the layou to show the same count.
I created a field on Company calls Count All and put the calculation
Created another Layout call All Calls Layout
I put Company Name and Count All fields. But still not showing the calculation.
It didn't worked. How does it update it automatically.
If correctly set up, it will update automatically.
Do you have a relationship linking Company to Query by CompanyID?
Is your new All Calls layout based on the Company table? (what is specified in "Show Records From" in "Layout Setup..."?)
I dont have relationship link between two tables. The relation is from Company=Client=Query. But companyID is in Query table.
Yes, the All Calls layout base is on the Company table. (Shoe Records From "Company")
Are these the match fields in your relationships?
Company::__pkCompanyID = Client::_fkCompanyID
Query::_fkCompanyID = Client::_fkCompanyID
where the __pk field auto-enters a unique identifier and the _fk fields are simple data fields (number for serial number or text for UUID strings)?
For a given record in company, how many records might there be in Client linked to that company record?
It's possible that what you have can be made to work. It's also possible that adding a new Tutorial: What are Table Occurrences? of Queries that is directly linked by companyID to Company can allow you to show data from the new occurrence of Quries.