I have the following code:

prodList = [SELECT ServicePartner__r.Name, ServicePartner__r.BillingAddress, ServicePartner__r.BillingStreet
            FROM Product2 
            WHERE id = :productId AND IsActive = true
            LIMIT 10];
Address adr = prodList[0].ServicePartner__r.BillingAddress;
System.debug('Address str ' + (adr != null? adr.getStreet(): 'null'));
System.debug('BillingStreet ' + prodList[0].ServicePartner__r.BillingStreet);
System.debug('Name ' + prodList[0].ServicePartner__r.Name);
  • If I run it logged in, the log shows everything right:

08:39:06:017 USER_DEBUG [29]|DEBUG|Address str San Miguel 1

08:39:06:045 USER_DEBUG [27]|DEBUG|BillingStreet San Miguel 1

08:39:06:045 USER_DEBUG [28]|DEBUG|Name Test Community

  • If I run it with the Guest User, the log shows null for the address but not for the Account name:

09:00:55:137 USER_DEBUG [29]|DEBUG|Address str null

09:00:55:137 USER_DEBUG [30]|DEBUG|BillingStreet null

09:00:55:137 USER_DEBUG [31]|DEBUG|Name Test Community

He have set permission to the guest profile for the account object and for the BillingAddress field as shown bellow: Billing address permissions

Do you know what else needs to be done?

Thank you

  • Go through OWD and Sharing settings of the object once.
    – Sikha Baid
    Nov 3, 2017 at 9:19
  • I changed it to public read only and it worked, post it as an answer and I will mark it as solved. Thank you
    – SebOB
    Nov 3, 2017 at 10:54
  • Glad! Posted as answer.
    – Sikha Baid
    Nov 3, 2017 at 11:02

1 Answer 1


Do check OWD and Sharing settings of the object once, that should help. Before changing the any sharing settings, please check that it does not affects business in any way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.