0

I need to an object and modify it's parent if condition are fullfiled but i'm encoutering an wierd behavior: in my SOQL the __r.field doesn't retrieve the fields values:

Below my anonymous code:

list<FLU_PaymentDeadline__c> pdl = [Select FLU_Contract__r.Name, 
FLU_Contract__r.FLU_ReviewAutoPay__c, SystemModstamp, FLU_PaymentMeans__c
                                    FROM FLU_PaymentDeadline__c 
                                    where FLU_PaymentMeans__c = 'CB'];
system.debug(pdl);

My debug is the following enter image description here

I can see the contract even if I did not query it and cannot see any field on the contract.

I tried with the query editor the same query:

enter image description here

Here i got what i want.

Can anybody else encoutered this kind of behavior already? I did check my profiles right in case it had something to do with it but I got access on all fields required.

7
  • What if you do system.debug(pdl. FLU_Contract__r); ? It could be just a debug that does not show relationship, but they are actually queried
    – kurunve
    Jul 28, 2020 at 9:28
  • @kurunve it says :"Variable does not exist: FLU_Contract__r" I tryed aswel debugging just the field (FLU_Contract__r.FLU_ReviewAutoPay__c) same error. Jul 28, 2020 at 12:01
  • There is a typo on my snippet, it should be without space in between -- system.debug(pdl.FLU_Contract__r);
    – kurunve
    Jul 28, 2020 at 12:07
  • Yeah i saw but still not working Jul 28, 2020 at 12:14
  • @kurunve you were right in your first answer: "It could be just a debug that does not show relationship, but they are actually queried" I answered my question below you can check it. Thanks Jul 28, 2020 at 12:24

2 Answers 2

1

Ok i got the answer, and it's a stupid one...

It appears that as I query a list, if I debug it I don't have the debug information of the parent. I have to debug element by element to see the parent relationship.

list<FLU_PaymentDeadline__c> pdl = [Select FLU_Contract__r.Name, 
FLU_Contract__r.FLU_ReviewAutoPay__c, SystemModstamp, FLU_PaymentMeans__c
                                    FROM FLU_PaymentDeadline__c 
                                    where FLU_PaymentMeans__c = 'CB'];
system.debug(pdl[0]);

Will show the parents fields.

0

If Profile level FLS and CRUD accesses are given, you should check the sharing settings of the contract object.

1
  • Did that aswell, sharing settings are Public Read/Write Jul 28, 2020 at 12:13

You must log in to answer this question.

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