1

I have 2 objects Case (Case) and LiveMessage Session (LiveText__Conversation_Header__c)

when I am querying

SELECT Id,  Case.LiveMessage_Session__r.LiveText__EndedTime__c  FROM Case

I am getting the following output - enter image description here

When I am doing direct query I am getting following output

Query

SELECT Id, LiveText__EndedTime__c FROM LiveText__Conversation_Header__c

OUTPUT - enter image description here

Note: I have created a look up field in Case which is pointing to Live message field, With that also I'm getting the same issue.

Lookup screenshot below: enter image description here

4
  • I think what you are seeing is just the result of the Developer Console's inability to correctly parse the query results. If you execute this query in anonymous Apex you will see the results are there. Try System.debug([SELECT Id, Case.LiveMessage_Session__r.LiveText__EndedTime__c FROM Case]); – Folkert Jul 3 '18 at 13:15
  • Hi, Nice idea but it is showing the id alone. second field it self is not coming. – Mobidoubts Jul 3 '18 at 14:13
  • 1
    It also looks like you are confusing LiveMessage Session and LiveMessage Header objects. – Folkert Jul 3 '18 at 15:03
  • Live Message Session is the label name and LiveText__Conversation_Header is the object name... No confusions – Mobidoubts Jul 16 '18 at 8:17
2

Try following relationship query.

Case is parent and LiveText__Conversation_Headers__c is child

Here I'am querying from case level,

SELECT Id,(select id,LiveText__EndedTime__c FROM LiveText__Conversation_Headers__r) from case 

or

LiveText__Conversation_Headers__c is parent and case is child

Try below query in Query Editor

SELECT Id,LiveText__Conversation_Header__r.LiveText__EndedTime__c FROM Case where LiveText__Conversation_Header__r.LiveText__EndedTime__c!=null
5
  • Hi Thanks for the quick reply. with 1st query I'm getting 3000 rows but all are blank and 2nd query is throwing error. – Mobidoubts Jul 3 '18 at 12:23
  • with respect to above comment pplease find the error here: Didn't understand relationship 'LiveText__Conversation_Header__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. – Mobidoubts Jul 3 '18 at 12:24
  • Please go to case object and fields ----> copy the lookup name for LiveText__Conversation_Header [Exact name] and then add __r then write "lookupname_r.LiveText__EndedTime__c " – SFDC Learner Jul 3 '18 at 12:27
  • Please check soqlquery basics: trailhead.salesforce.com/en/modules/apex_database/units/… – SFDC Learner Jul 3 '18 at 12:28
  • Hi! I followed the steps but still I'm getting the values like (null LiveMessage_Session__r) for the query "SELECT Id, LiveMessage_Session__r.LiveText__EndedTime__c FROM Case " – Mobidoubts Jul 3 '18 at 12:33
1
SELECT Id,LiveText__Conversation_Header__r.LiveText__EndedTime__c FROM Case  

As you have mentioned pls use the LiveText__Conversation_Header__c is the child use the relationship query appending __r at last from case. you can get __r.name or any other field from the child object.

3
  • Hi Thanks for your reply. In both the ways I'm getting this error "Didn't understand relationship 'Case__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names" – Mobidoubts Jul 3 '18 at 12:26
  • can you please go to case and show me the lookup name of the parent api.add screnot in the question – SFDC Learner Jul 3 '18 at 12:36
  • Hi I've added the screenshot please check in the question. – Mobidoubts Jul 3 '18 at 13:08
0

I got the answer that the value can be null, so if you execute this SOQL it will return blank rows.

When you execute that SOQL in Developer console in execute Anonymous mode then SOQL engine automatically includes Id in any query result.

for more details visit: SOQL results returning RecordTypeId which is not included in query

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.