Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Matrix field using JavaScript

VladimirSekerka
Contributor III

Hello All.

I am trying to get and set values of Matrix field in custom object.

 

When I use $CM.getFieldValue(22486), I get

 

Snímka.PNG returns

and  $CM._field[22486] returns

Snímka2.PNG

 

I have a columnList and rowList numbers there.

But I am not able to get or set the values actual lists.

On the other hand, I am not sure, if I should access the values of columnList and rowList directly through _field array of $CM. But the getFieldValue returns a Key values I do not know how to get/set lists with.

 

Do you have any idea how should I set and get the values to/from matrix field properly?

 

Is there any documentation about how to set or get other types of fields as well?

Without such basic documentation the enhancing of Archer (even basic) is only trial and error (and rarely success).

 

Thank you

 

Vladimir

1 REPLY 1

VladimirSekerka
Contributor III

Hello All. 

I found the way finaly to access and change matrix field value usingJavaScript.

 

When the record is in edit mode, the matrix is displayed as an array of checkboxes.

I am able to get value of the checkbox (true/false) by

 

$('input[id$="f22486c_Owner_row2_2-3"]')[0].checked

 

where 22486 is Matrix field ID,  2 in row2 is row number and 2-3 is row-column number. I havo no idea why, but the rows are numbered as multiple of 2 (i-e. 2, 4, 6, 8,...).

 

I am able to toggle the value of the checkbox by  

$('input[id$="f22486c_Owner_row2_2-3"]')[0].click()

 

If you want to set or clear the value of the checkbox, you have to first check the current value and toggle only when you need to change it.

 

This works only in edit mode of the record, but it is sufficient for my needs.

 

Enjoy.

 

Vladimir