0

Hoping someone has in idea into what is going wrong with history object record entry and sorting. Here is the soql query i'm running: SELECT Id,Field,OldValue,NewValue, CreatedDate FROM "ObjectName__History" where ParentId = 'xxxe000000UWxxx' order by CreatedDate desc

enter image description here

  1. First issue, if you see the created record which is supposed to be at the last when sorted 'desc' is at 3rd from bottom
  2. 'Last Modified By' is an custom field, looking up an contact, now this field is populated on insert and update. If we look at the history, there are bunch of updates seen on the field, however there was only 2 update done on it (each update has 2 record entries one with contact ids and other with Name). The latest update is not seen on the record but seen on history(strange!!!)

enter image description here

All in all the query as well as the actual related list both are showing incorrect chronology. In case someone has a solution to get this sort correct kindly help, as it seems createdDate is not helping much.

Regards

1 Answer 1

0

When two dates are the same in the history field you cannot depend on the DESC for the order, you might want to either filter out WHEN FIELD = 'Created' or move it to the botto of the list using APEX.For your second issue: always when a lookup field is updated it logs twice to the history object (once for the id, and once for the name). You can fetch only the names instead of ids using WHERE DataType != 'EntityId'.

1
  • Thanks @santiparris , I have logged a case with SFDC for both the issues: Issue 1 : Need to understand from SFDC, if manipulation with apex is the only way out Issue 2 : I am aware why the 2 entries for a lookup field, and filter to get only a single record, however issue was to understand the reason behind the difference b/w latest entry in the history object and on the UI (had refreshed, cleared cache and closed/open browser multiple times) Commented May 19, 2023 at 6:01

You must log in to answer this question.

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