app.api.call and buildUrl Filter list of results in v7.6.1

Hello everyone,

I wish to filter my list of results with the function app.api.call().

I know how to filter by Id ( app.api.buildURL('myCustomModule/Id') ) but if I want to filter by another field (custom field psc).

Here is my code of my last attempt (after searching on web) which is not working :

                             var urlc = app.api.buildURL('myCustomModule'), post_data = {psc: '3'};

                             app.api.call('GET', urlc, post_data, {

                                 success: function (data) {

                                     // my logic

                                 }

                             });

Thanks for your answer !

Best regards.

Parents
  • Hi gui,

    In order to make "GET" method you need to use "read". So, try this one;

    var url = app.api.buildURL("Accounts", null, null, {
        "filter": [{
            "psc": "3"
        }]
    });
    
    
    app.api.call('read', url, null, {
        success: _.bind(function(response) {
            // here is your success code
            console.log("Response", response)
        }, this),
        error: _.bind(function(error) {
            // here is your error code
            console.log("Error", error)
        }, this),
    });
    

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

Reply
  • Hi gui,

    In order to make "GET" method you need to use "read". So, try this one;

    var url = app.api.buildURL("Accounts", null, null, {
        "filter": [{
            "psc": "3"
        }]
    });
    
    
    app.api.call('read', url, null, {
        success: _.bind(function(response) {
            // here is your success code
            console.log("Response", response)
        }, this),
        error: _.bind(function(error) {
            // here is your error code
            console.log("Error", error)
        }, this),
    });
    

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

Children