function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
tsu kanetsu kane 

How to query all Chatter Files attached to a record?

Please tell me How to query all Chatter Files attached to a record by PHP.

=== Sample Code ===
$sforce_connection = new SforcePartnerClient();  
$soap_client = $sforce_connection->createConnection(PARTNER_WSDL_FILE, null);  
echo("ConectClassOK<br>");

try {  
    $login = $sforce_connection->login(LOGIN_ID, LOGIN_PASS); 
    $login_info = get_object_vars($login);  
    $session_id = $login_info['sessionId'];  
    echo "LoingOK -> Session Id : " . $session_id . "<br>";  
} catch (Exception $e) {  
    var_dump($e); 
}

try{
    $query = 'SELECT PostCount, ParentId FROM ChatterActivity';
    $response = $sforce_connection->query($query);
    $queryResult = new QueryResult($response);

    for ($queryResult->rewind(); $queryResult->pointer < $queryResult->size; $queryResult->next()) {
        print_r($queryResult->current()->ParentId);
    }

    ・・・ The point which isn't understood ・・・
======
Prateek BhattPrateek Bhatt
Hi Kane,

You can use below SOQL query to fatch the chatter files for a record 
select id, title, parentid from feeditem where type = 'ContentPost' and parentid = 'RecordId'

Thanks,
tsu kanetsu kane
Hi Prateek Bhatt,

Thank you very much.
It was possible to get the title below.

---
SObject Object ( [type] => FeedItem [fields] => stdClass Object ( [Title] => テストファイル [ParentId] => 0056F000006aHNoQAM [RelatedRecordId] => 0686F000003JCUeQAO ) [Id] => 0D56F00003kdMjOSAU ) SObject Object ( [type] => FeedItem [fields] => stdClass Object ( [Title] => test [ParentId] => 0056F000006aHNoQAM [RelatedRecordId] => 0686F000003IralQAC ) [Id] => 0D56F00003hP98VSAS )
---

ContentData is thinking to need to preserve file substance.
How should it be done?

Thanks,
Prateek BhattPrateek Bhatt
Hi tsu,

You need to get the ContentData also along with feeditem title. Right?

Thanks,
tsu kanetsu kane
Hi Prateek Bhatt,

Yes, ContentData is necessary.
I think I'll make a program which acquires a file and does some processing.

Thanks,