Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Display subsummary data

Featured Replies

Hello,

I have a simple subsummary report in my database and am having trouble displaying the subsummary data on a web page using CDML.

My report consists of a subsummary part with two fields in it:

1) subject

2) subject count (a summary count of subject)

In the FileMaker database I get a result like:

Biology 5

History 10

Science 2

etc.

I don't know how to replicate this on the web.

I've tried sorting by subject and displaying the two fields within [FMP-Record] tags, but, of course, the subject field is repeated for every record in the found set and the subject count field gives only a count of all found records.

I can't hard code a separate find for each subject because there are many subjects and they can change at any time.

I know I could use a value list to display a list of the subjects, but I can't figure out how to get the subject counts to display.

I would appreciate any help.

Thanks!

You can use either Javascript or Portals to achieve this.

Here is a method using [FMP-InlineActions] and Javascript:

Summaries

Here is a Javascript method that summarises a SORTED list:

<script>var tot_qty = 0; var loc_total = 0; var curr_loc = "Location";

[FMP-Record]

if (curr_loc == "[FMP-Field:location_name]")

	{

	loc_total += [FMP-Field:qty];

       tot_qty += [FMP-Field:qty]; }

else

    {

    document.write(curr_loc + " " + loc_total + "<br>");

    curr_loc = "[FMP-Field:location_name]";

    loc_total = [FMP-Field:qty];

    tot_qty += [FMP-Field:qty];

    } ;     	

[/FMP-Record]

document.write(curr_loc + " " + loc_total + "<br>");

document.write("Total Quantity: " + tot_qty);</script>

Hope this helps.

Garry

  • Author

I will give that a try. Thank you!

  • Author

I've tried to implement the solution, but I must be doing it wrong.

I put this code on body of the page on which I wish to display the results:

<script>var tot_qty = 0; var loc_total = 0; var curr_loc = "Location";

[FMP-Record]

if (curr_loc == "[FMP-Field:location_name]")

{

loc_total += [FMP-Field:subject_count];

tot_qty += [FMP-Field:subject_count]; }

else

{

document.write(curr_loc + " " + loc_total + "<br>");

curr_loc = "[FMP-Field:location_name]";

loc_total = [FMP-Field:subject_count];

tot_qty += [FMP-Field:subject_count];

} ;

[/FMP-Record]

document.write(curr_loc + " " + loc_total + "<br>");

document.write("Total Quantity: " + tot_qty);</script>

I get to that page using a link that finds all records with something in the subject field.

I don't see anything on my results page after I click the link.

Should I be putting in a value for "Location" or "location_name"?

I know you said this solution was involved both java script and inline action. I am new to inline action and am not sure how to implement that part. Could you tell me what I am doing wrong?

Thank you very much!

Lisa

Lisa,

"Location" may be "subject" in your case. It is the field that is being sorted (with: &-sortfield=subject&) and the summaries are based on. Use the field name appropriate to your database.

Instead of [FMP:subject_count] you may just want to increment a counter, depends on your database. For example;

<script>var total = 0; var subj_total = 0; var curr_subj = "Subject";

[FMP-Record]

if (curr_subj == "[FMP-Field:subject]")

{ 

subj_total += 1; 

total += 1; }

else 

{ 

document.write(curr_subj + " " + subj_total + "<br>"); 

curr_subj = "[FMP-Field:subject]"; 

subj_total = 1; 

total += 1; 

} ; 

[/FMP-Record]

document.write(curr_subj + " " + subj_total + "<br>");

document.write("Total: " + total);</script>

Good Luck.

Garry

  • Author

Garry,

It works beautifully. Thank you very much for all your help!

Lisa

  • 9 months later...

Thanks Garry, I used your javascript code too. Very helpful as I find both javascript and getting summary fields displayed within FMP rather tricky.

Couple of probs I ran into that may help others...

Put '&-max=all' in your calling url or only the first 25 records seem to get processed.

If the sort field name has a space in it use '+' not '%20' in the url.

Don't put any html comments after <script> to hide for non-supporting browsers, it seems to break it for some reason.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.