Is there some method or property to get the count of a multi-value field without iterating with .getNextFieldSibling?


var MV_Field = $display.getView().properties.controls.fieldBuilder.getField("MultiValueField_Name");
while (MV_Field.getNextFieldSibling() != null) {
    count = count+1;
    MV_Field = MV_Field.getNextFieldSibling();

2 Answers 2


I thought you could call field.getValues() to get all the field's values as an array. Then, you'll be able to count the number of values inside the array

so you would need to do something like

var values = MV_field.getValues();
var nrOfValues = values.length;


getValues() is indeed not the right way to get the items, although the naming does look confusing. The solution proposed in the accepted answer does return the number of items fields, but might be risky If i have a multi-value field with two items, and click the plus icon, but don't fill in any value, then the statement

 var count = fieldObj.getElement().parentElement.children.length - 1; 

returns 3, although, the actual number of values is two (as i didn't fill in a third value yet.

I did some quick testing and debugging with the gui extensions, and found out you can also get the values like this

 var fieldBuilder = $display.getView().properties.controls.fieldBuilder;
 var count = fieldBuilder.properties.dataRoot.getElementsByTagName("MultiValueField_Name").length;

That gives you the exact number of values entered, and also gives you direct access to the items (as an xml object).

  • 1
    field.getValues() on a multivalued field just returns you the first value, its length is always 1 (unless the field has no value). Oct 31, 2013 at 15:51

Do this way

var fieldObj = $display.getView().properties.controls.fieldBuilder.getField("FieldName");
var count = fieldObj.properties.element.parentElement.children.length - 1;


var count = fieldObj.getElement().parentElement.children.length - 1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.