How to retrieve list views of any salesforce object using API?
Solution 1
This is an old question, but, using the REST API and Salesforce's query language, you could use the endpoint:
{your instance url}/services/data/v32.0/query?q=SELECT Id,Name FROM {object type}
OR
Use the endpoint:
{your instance url}/services/data/v32.0/sobjects/{object type}/listviews
Some examples:
To get all listviews: https://na16.salesforce.com/services/data/v32.0/query?q=SELECT Id,Name FROM ListView
To get all listviews with object type of account: https://na16.salesforce.com/services/data/v32.0/sobjects/Account/listviews
In PHP:
$url = "{your instance url}/services/data/v32.0/sobjects/Account/listviews";
$headers = array('Authorization: OAuth ' . {your access token});
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, TRUE );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers);
$requestBody = curl_exec ($ch);
$result = json_decode($requestBody, true);
Of course you'll need to login first through OAUTH to get an access token and instance URL.
Solution 2
If it's SOAP api that you are looking for, it's called describeSObject
- for specific object, or 'describeGlobal' - for all your org's data.
See the reference link below for SOAP message: http://wiki.developerforce.com/page/Sample_SOAP_Messages_(10.0_API)
user1808669
Updated on June 04, 2022Comments
-
user1808669 almost 2 years
I want to retrieve all list views of any salesforce object through API. How to do that?