Use GetData API in file-based module

LabKey Support Forum (Inactive)
Use GetData API in file-based module alanv  2014-05-13 12:57
Status: Closed
 
Hey Chris,

When you create a JavaScript report LabKey creates the appropriate configuration for you. If you select "Use GetData API" it creates a queryConfig object that conforms to the JavaScript GetData.rawData requirements. In order to manually use the GetData API you'll need to write some code that looks something like this:

<script type="text/javascript">
    var config = {
        source : {
            type: 'query',
            schemaName: '<The Schema Name You Need Goes Here>',
            queryName: '<The Query Name YOu Need Goes Here>'
        },
        success: function(response) {
           // Your Success function goes here.
           console.log(response);
        },
        failure: function(response) {
            // Your failure function goes here.
            console.error('Error occurred during GetData request');
            console.log(response);
        }
    };

    LABKEY.Query.GetData.getRawData(config);
</script>

You can also specify the list of columns you want, the sorts you need, filters, grouping, and more. All of the GetData config options are listed in the documentation that I linked above.