function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
juhi dhiverjuhi dhiver 

How to fetch all the child records based on the particular value say (Category -xyz) using a javascript.I found few scripts but hard to match my requirements .Please help .

Shruti SShruti S
For this requirement you will need to write an Apex method which would query the child records. That being said, there are two ways by which you can invoke Apex from JavaScript.

Method 1
By using RemoteAction calls from JavaScript. You can annotate you apex method with 'RemoteAction' and call that method  in JavaScript.
Eg:
Apex Code 
public class JuhiDhiver {
    @RemoteAction
    public static Integer addNumbers( Integer a, Integer b ) {
        return a + b;
    }
}
Visualforce
<apex:page controller="JuhiDhiver">
    <script type="text/javascript">
        JuhiDhiver.addNumbers(
            10,
            20,
            function( result, event ) {
                alert( "Sum is " + result );
            }
        );
    </script>
</apex:page>

Method 2
By using webservice methods. The method in Apex class which needs to be accessed in JavaScript is exposed as a webservice.
Apex Code
global class CalculatorSOAP {
    webservice static Decimal add( Decimal a, Decimal b ) {
        return a + b;
    }
}
Visualforce
<apex:page>
    <script type="text/javascript" src="/soap/ajax/39.0/connection.js"></script>
    <script type="text/javascript" src="/soap/ajax/39.0/apex.js"></script>
    <script type="text/javascript">
        sforce.connection.sessionId = "{!GETSESSIONID()}";
        
        var sum = sforce.apex.execute(
            "CalculatorSOAP",
            "add",
            {
                a : 10,
                b : 20
            }
        );
        
        console.log( sum );
    </script>
</apex:page>

Please let me know if you have any more doubts.