How to prepare Dependent Picklist using Javascript for External Objects?

I want to prepare Custom dependent pick-list using JavaScript for external many to many relationship objects.

Let say , “Sample” and “Sample 2” are two objects. "Sample Junction " is a junction object.

Here There is custom pick-list which have “sample” objects ids.

Based on selection of “Sample” object id, i want to prepare pick-list which have “Sample 2” records values. means it has to check the values in junction object.


How to achieve this?

Look into the “Filters” function of the reference field.  There you can add a filter of Sample 2 records that are included in the reference field,  based on whether they also have ‘Sample’ in thier row of the junction object. 

Can I get a example on using the ‘Filters’ function? I have one more quick question, lets say that I can have an ‘id’ from a snippet. Can I use(reference) this ‘id’ in a different snippet?