I'm currently using simple-salesforce to retrieve data from various the object in salesforce, but I would also need to download the post in chatter of the associated object.
For instance, with an object project_table__c
I need to get the associated post of each project.
Project_id | Chatter post |
---|---|
1 | test |
2 | hello |
2 | word |
2 | bird |
I might also be possible to get it with the rest API but I don't where I should go from here:
from simple_salesforce import Salesforce
import os
username="username"
password=os.environ['SALESFORCE_PASSWORD']
security_token=os.environ['SALESFORCE_SECURITY_TOKEN']
domain="test"
sf = Salesforce(username=username,password=password, security_token=security_token,domain=domain)
report_results = sf.restful('chatter', method='GET')
print(report_results)
How could I achieve it?
The general table to store Chatter posts is FeedItem. You can query it directly but it'll have all chatter posts across all objects, you'd need to filter it with something like select id, parentid from feeditem where parent.type = 'project_table__c ' limit 10
. Might get nasty quick and problematic if you need more fields from the parent object.
You probably have a "more specific" table project_table__Feed
(similar to how you have autogenerated project_table__History
, project_table__Share
...). The reverse relationship name for this table will be Feeds
so see how this works for you?
SELECT Id, Name,
(SELECT Title, Body FROM Feeds)
FROM Project_Table__c
LIMIT 20
So try querying that with "simple" and see how it goes?
There's also whole Chatter Connect REST API... More reading but hey, maybe simpler access?