How can I Get random List with V10 API

Hello,

I have to get Random List for Leads Module in my fronted using V10 API.

So How it's possible to random Leads display?

Thanks

Dipesh Patel

Offshore Evolution Pvt Ltd.

Parents
  • Hi Offshore,

    Fastest way would be having a custom end point(Extending Endpoints - Developer Guide) for Leads. There you can run a query agains Leads module with

    ORDER BY RAND()
    

    that would return you random leads in every query.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

  • We are using V10 Api.

    $job_arguments = array(

        "fields" => array('id', 'first_name', 'last_name', 'date_entered', 'date_modified'),

        "max_num" => '200',

        "offset" => '0',

        #"order_by" => "rand():DESC"

    );

    $url = "https://xxxx.sugarondemand.com/rest/v10/Leads/filter";

    $get_Leads_lists = $Sugarapi->call($url, 'GET', $job_arguments);

    Is there any way to working default Endpoint through random list fetch ?

    Thanks

    Dipesh Patel

    Offshore Evolution Pvt. Ltd.

  • Hi Dipesh,

    I also tried to find a way to pass rand() to order_by and couldn't find. Then i recommended you to have a custom end point.


    I will be thinking about getting random records using the existing endpoints but i don't think it would be simple and i would assume that it would cost you more (as api calls/calculations etc)

    Just having a simple custom endpoint runs a simple query and returns the results. That's all.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

Reply
  • Hi Dipesh,

    I also tried to find a way to pass rand() to order_by and couldn't find. Then i recommended you to have a custom end point.


    I will be thinking about getting random records using the existing endpoints but i don't think it would be simple and i would assume that it would cost you more (as api calls/calculations etc)

    Just having a simple custom endpoint runs a simple query and returns the results. That's all.

    Best Regards

    Tevfik Tümer

    Developer Support Engineer

Children