Search code examples
gooddata

How to add a 'where' condition to 'execution.getData' in a gooddata-js API


I'm using gooddata-js API and I need some help to include 'where' condition into 'execution.getData' method. For example: I need compare a date month/year attribut like [/gdc/md/{PROJECT_ID}/obj/OBJ_ID] = [/gdc/md/{PROJECT_ID}/obj/OBJ_ID/elements?id=24235]

I tried use the condition below but didn't work!

sdk.execution.getData(projectId, elements,'[/gdc/md/{PROJECT_ID}/obj/OBJ_ID] = [/gdc/md/{PROJECT_ID}/obj/OBJ_ID/elements?id=24235]').then(function(dataResult){

     var headers = dataResult.headers.map(function (h) {
            return h.title;
     });
     var data1 = dataResult.rawData;
}'

I expect receive data into dataResult.headers, but the dataResult.rawData is empty.


Solution

  • according GooddataJS documentation, 3rd param of getData method is executionConfiguration object https://sdk.gooddata.com/gooddata-js/api/classes/execution.html#method_getData

    so I can imagine, that something like:

    {
        where: {
            "/gdc/md/YOUR_PROJECT_ID/obj/YOUR_DATE_DATASET_ID": {
                "$between":[-1,-1],
                "$granularity":"GDC.time.year"
            }
        }
    }
    

    would apply date filter during execution, or

    {
        where: {
            "/gdc/md/YOUR_PROJECT_ID/obj/YOUR_ATTRIBUTE_DISPLAY_FORM_ID": {
                "$in":[{
                    "id":"/gdc/md/YOUR_PROJECT_ID/obj/YOUR_ATTRIBUTE_ID/elements?id=SELECTED_ATTRIBUTE_ELEMENT_ID"
                }]
            }
        }
    }
    

    would apply positive attribute filter