I am trying to set the value of one object in a custom object to be the same as the value of another object before deleting the first object. When I use the assignment operator, nothing happens although I'm certain that the Account__r of dbc is populated. Does anybody know why this doesn't work?
for ( Customer__c dbc : [SELECT Account__c, Account__r.Priority__c, Unique_Id__c FROM Customer__c WHERE Unique_Id__c IN :customers.keySet( )])
{
Customer__c c = customers.get( dbc.Unique_Id__c );
// replace the account of the last added customer if the priority is less
// than that of the previous entry
// I could not find the solution to this problem. I cannot access
// c.Account__r.Priority__c without using a DB call and could find no solution online.
if ( accountMap.get( c.Account__c ).Priority__c.compareTo( dbc.Account__r.Priority__c )
< 0 )
{
c.Account__r = dbc.Account__r;
}
entriesToBeDeleted.add( dbc );
}
thanks in advance
< 0
in the compareTo(..) method? This doesn't test for equality; it tests for lexicographically precedes.