DEV Community

Takahiro Kudo
Takahiro Kudo

Posted on

Searching object name attached Attachment

I had to extrace object name attached Attachment object when I copy object records to new Salesforce Org.

// Get Attachments
List<Attachment> atts = [SELECT ParentId From Attachment];
Set<Id> idSet = new Set<Id>();
for (Attachment att : atts) {

// Get Object Name
Set<String> objSet = new Set<String>();
for (Id rid : idSet) {
  Schema.SObjectType name = rid.getSObjectType();

// dump

Top comments (0)