EntityParticle would be the best source for this for objects you'll typically interact with:
Represents each element of a field that can be presented in a user
interface. Contrast EntityParticle with FieldDefinition, which
represents each element of a field defined in the Metadata API.
And reference IsLayoutable
If true, the field can be assigned to a layout.
As such, you can do the following:
SELECT QualifiedApiName,
(SELECT IsLayoutable FROM Particles)
FROM FieldDefinition
WHERE EntityDefinition.Label = 'Task' ORDER BY QualifiedApiName ASC
Where IsLayoutable = true
should highlight the fields that are displayed in the UI (Setup).
Notes
That will return available fields for both Activity & Task that are presented separately in the Object Manager
I said "should" - as there's a small amount of exceptions across several objects. For Task, this is
I also said "objects you typically interact with" as there are some objects that display in Object Manager
that are not layoutable so all fields would be false
even though fields display. I found a couple examples in my dev org
Since you're using simple-salesforce and doing a sub-query - I'd suggest flattening the data before passing it to pandas.
data = sf.query("SELECT QualifiedApiName, (SELECT IsLayoutable FROM Particles) FROM FieldDefinition WHERE EntityDefinition.Label = 'Task' ORDER BY QualifiedApiName ASC")
records = [];
for rec in data['records']:
if(rec['Particles'] is not None):
records.append(dict(QualifiedApiName=rec['QualifiedApiName'], isLayoutable=rec['Particles']['records'][0]['IsLayoutable']))
else:
records.append(dict(QualifiedApiName=rec['QualifiedApiName'], isLayoutable=False))
print(pd.DataFrame(records))
That should print
|
QualifiedApiName |
IsLayoutable |
0 |
AccountId |
False |
1 |
ActivityDate |
True |
2 |
CallDisposition |
True |
3 |
... |
... |
Task
andEvent
are both types ofActivity
, and they share some fields, potentially complicating this question.