Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Gabil
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?

 

Thanks,

Gabil Kazimov

4 REPLIES 4

Anonymous
Not applicable

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.

 

Thanks,

Gabil

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

Thanks David. Much appreciated.