I have set history tracking for my Custom Object and set a Lookup field for my referenced Object.
CustomObjectX_c[Field1,Field2,Account_c]
Here Account__c is a lookup field to the Salesforce Account Object.
Whenever there is any change in Account_c it reflects back in CustomObjectX_History with two entries.
Say old Account_c is 001ABC (named A1)and new Account_c is 001XYZ (named A2).
entry1 for Account.Id:
OldValue: 001ABC
NewValue: 001XYZ
Field/Event: Account__c
entry2 for Account.Name:
OldValue: A1
NewValue: A2
Field/Event: Account__c
Problem:
Since the Field/Event is same in both these records it is hard to distinguish which maps to Account.Id and which maps to Account.Name.
Currently I am querying back the Salesforce with each NewValue to check whether an Account with that Id exits.
check for entry 1:
SELECT id from Account where id = '001XYZ' => true
check for entry 2:
SELECT id from Account where id = 'A2' => false
Is there a smarter way to prevent Account.Name records being mixed up with the History Tracking ?