API call to retrieve Leads/Contact from ProspectLists(Target List) which are linked after a certain date

How to Make an API call to retrieve Leads from ProspectLists which are linked after a certain date
I'm making an API call to ProspectLists with a filter added as date_modified >= Specific date-time, but this is filtering date_modified filed on leads table, not on  ProspectLists table. 

Parents
  • There is no dedicated API call yet for that specific information.

    Perhaps you could define a custom collection definition on the ProspectList module to enable something like 
    .../rest/v10/ProspectLists/<id>/collection/leadlist

    But unfortunately the documentation for such a custom definition of a collection is still not available. Perhaps you can have a look on collection definitions in vardef files.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Hi Harald,
    Thank you for your quick response. Is there a table between Lead/Contact and ProspectLists? I'm looking for leads/Contacts linked to ProspectLists after a specific date. 
    My API calling this - /{ProspectLists }/{id}/{Link}/{leads} with filter date_modified >= Specific Date.

    This does not bring me leads that are linked to ProspectLists after a specific date if I add existing leads.
    It's working only if I add brand new leads to ProspectLists.

  • The relationship between ProspectLists and Leads is stored in the table prospect_lists_prospects which contains the id of the ProspectList, the Type of the linked record (e.g. Leads), the creation/modification date of the link and a deleted flag.

    The API call - /{ProspectLists }/{id}/{Link}/{leads} with filter date_modified >= Specific Date delivers the Leads which were created after the Specific Date.

    The only way to filter the relationship date is to write an own API endpoint - or in Enterprise edition and above - a custom query to retrieve the links directly from the database.

    As a test I created such a little API function just for that usecase in custom/clients/base/api/customRelateApi.php which I attach here. Perhaps you can use it as a template for own developments. Please check the comments and the code and do not test it in production !!! but in a local test environment.

    customRelateApi.zip

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Reply
  • The relationship between ProspectLists and Leads is stored in the table prospect_lists_prospects which contains the id of the ProspectList, the Type of the linked record (e.g. Leads), the creation/modification date of the link and a deleted flag.

    The API call - /{ProspectLists }/{id}/{Link}/{leads} with filter date_modified >= Specific Date delivers the Leads which were created after the Specific Date.

    The only way to filter the relationship date is to write an own API endpoint - or in Enterprise edition and above - a custom query to retrieve the links directly from the database.

    As a test I created such a little API function just for that usecase in custom/clients/base/api/customRelateApi.php which I attach here. Perhaps you can use it as a template for own developments. Please check the comments and the code and do not test it in production !!! but in a local test environment.

    customRelateApi.zip

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Children