function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
javierjiesjavierjies 

Different Owners

Hello everyone!!!

 

 

I have an object (named percentages) with two lookup fields, one goes to Contact, and the other one to the custom object Balance.

 

I want to obtain with a SF class and a VF Page, those percentages where the owner of the Contact is not the owner of the balance.

 

Apparently, It's easy to deploy, but here is the issue; I've almost 10000 records for each one of those objects, so It's gives me a lot of; "too many records" error message!

 

Any idea?!?  Please I do need this information!!

 

Thanks in advance!!!!!! 

Best Answer chosen by Admin (Salesforce Developers) 
ErikssonEriksson

Well, you can create a formula field, here I would like to call "DifferentOwner__c", and the logic could be like this:

 

IF(Percentages__c.Contact__r.OwnerId <> Percentages__c.Balance__r.OwnerId, 'true', 'false')

Then you can simply retrieve the records like this:

 

[select Id from Percentages__c where DifferenctOwner__c = 'true']

and in this case, you will not get error as long as you don't have 10000+ records which the owner of the Contact is not the owner of the balance.