Expand my Community achievements bar.

SOLVED

Field to count number of subforms (patients)

Avatar

Level 1

Hi,

New to Designer and making some headway...

I've got a field to count the number of patients on a form. Each patient's details are in a subform, which is within a container. There's buttons to add or delete a patient/subform which is working fine.

I'm struggling with getting the field to show the number of patients/subforms.

I've put this code into the 'calculate' event of the field:

$.rawValue=Count(PatientContainer.PatientDetailsSubform.Line1[*])

'Line1' is an element withing the PatientDetailsSubform. I did have it as 'Surname' but the count only goes up when it's non-null and even then it only seems to count the first subform. To be honest, Line1 doesn't work at all...

Thanks in advance,


Simon.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi Simon,

You can use the instanceManager() to count the numer of subforms. As you have mentioned PatientDetailsSubform contains the information about the patient so you can count the instances of this subform to get the no.of patients.

var patientCount = PatientContainer.PatientDetailsSubform.instanceManager.count;

Thanks,

Bibhu.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 9

Hi Simon,

You can use the instanceManager() to count the numer of subforms. As you have mentioned PatientDetailsSubform contains the information about the patient so you can count the instances of this subform to get the no.of patients.

var patientCount = PatientContainer.PatientDetailsSubform.instanceManager.count;

Thanks,

Bibhu.