0

I created a report on Contact History and I summarized the report by Contact Id. I need to use the Edit Date of that report to mass update records but the summary shows multiple lines from when the record was edited. What can I do to the report so only the latest date shows? Only one line per Contact Id. I was thinking about a formula but I don't know what kind of formula I can create, I don't have many options. Thanks in advanced.

1 Answer 1

0

I'm not sure if you're limited to a report, but if you have the ability to use SOQL/APEX, then this should get you the information you want:

SELECT Id, (
    Select OldValue, NewValue 
    FROM Histories ORDER BY CreatedDate DESC LIMIT 1
    ) 
FROM Contact

So you might do some anonymous apex like so:

List<Contact> contacts = 
    [SELECT Id, (
    Select OldValue, NewValue 
    FROM Histories ORDER BY CreatedDate DESC LIMIT 1
    ) 
    FROM Contact];

for(Contact c : contacts)
{
    if(c.Histories.size() == 1)
        // Do something more useful than this 
        System.debug(c.Histories[0].OldValue);
}
1
  • LyBer, Thanks for the update. The only issue is, I need to exclude 2 users that edited the records, API User and Data.com User. Data.com doesn't have a UserId so I can only exclude that user by the alias. and I don't need the OldValue and NewValue but the EditedDate and EditedBy fields. I tried using workbench but I am limited to use Contact History and I don't get the Contact information when I do that. Any other way you can think of doing this using Apex?
    – Leo
    Aug 25, 2015 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .