You need to sign in to do that
Don't have an account?
Cross-object formula returns null on Apex Test Execution
Dear Comunity, I hope all of you are safe and sound.
Is there any reason for cross-object formula returns null on apex test execution?
My test updated a field, then the System.debug shows the value from the cross-object formula, but it shows null even after querying it:
That's the piece of the ciode:
Test.startTest();
List<CC__c> cardlist = [SELECT Card_Id_CC__c,Card_Last_Modified_Date__c FROM CC__c WHERE Id = :e.Id];
CC__c cardtest = cardlist[0];
cardtest.Card_Id_CC__c = 'card12345';
update cardtest;
System.debug(cardlist);
System.debug('Card Last Modified date - CC__c.Card_Last_Modified_Date__c: ' +cardtest.Card_Last_Modified_Date__c);
RG__c rglist2 =[Select Card_Last_Modified_Date__c FROM RG__c WHERE ID=:r.id];
System.debug('This field must be equal to CC__c.Card_Last_Modified_Date__c '+ rglist2.Card_Last_Modified_Date__c);
Thank you all
just to make sure, the test class cannot see the data in org by default unless you use SeeAllData=true.
Thanks Likith Obbina,
I'm executing the test code with the standard System Administrator profile and View All Data is set to TRUE on System Permission.