Showing results for 
Search instead for 
Did you mean: 

Can Custom Object count number of records in the cross-reference field?

Contributor III

Hello community,


I have a question for Java Script experts: Can custom object determine if we have more than one record in the cross-reference grid on the layout?


If yes, is there some sample?



Gabil Kazimov


Archer Employee
Archer Employee

Gabil Kazimov,


No need to use a Custom Object for this. You can leverage the COUNTA() function in a calculated field to count the number of references. Details: COUNTA Function

Hi Scott,


Thank you for the prompt reply.


However I need to count number of records in the cross-reference field BEFORE saving the record. The goal is to prevent saving such records. Generally speaking I need a CONDITIONALLY  multi-select cross-reference field.




Gabil, you can use the following to see how many records are selected in a cross-reference field:

$('input[name*="SelectedValues' + rxRefFieldId + '"]').val();

Then you can get a count of that array and go from there.

 Advisory Consultant - Archer, an RSA Business

Thanks David. Much appreciated.