Search code examples
salesforcesoqlsalesforce-communities

Return blank records instead of No Records found from Salesforce


I am working on mobile app using SalesForce Mobile SDK and for a functionality to work, I am building the mapping between the customer_id and corresponding Address. So to have a mapping, I have modified the SOQL Query to get the customer_id value back once the query is executed.

This mapping works fine when there is Address is found. But when there is no address associated, I doesnot get any response. So, mapping a customer_id and put a null address in it, I would need the customer_id back even when address is not found.

To better explain: The following query doesnot return any result since there is no address found:

SELECT Account_vod__c,Address_line_2_vod__c, City_vod__c, Name FROM Address_vod__c WHERE Account_vod__c = '001e000000qVp8WAAS'

But I want to create a query such that if there are no records found, it would return something like:

enter image description here


Solution

  • Nested SOQL queries did the trick:

    SELECT Id, Name,(SELECT Id, Account_vod__c, Name, Address_line_2_vod__c, City_vod__c FROM Address_vod__r)FROM Account WHERE Id = '001e0000008Ch5nAAC' LIMIT 1