2

I have a salesforce query that extracting users time report

SELECT ID,Logged_Date__c ,CreatedBy.Email, CreatedBy.id, CreatedBy.Name, Time_Spent_Hours__c, Activity__c, CaseId__r.CaseNumber, CaseId__r.Account.id, CaseId__r.Account.Name , Utilized__c
FROM Time_and_Placement_Tracking__c 

The Activity__c returns with the activity text.

I was trying to use Activity__c.Id, Activity__r etc. but all returns with error.

Is there a way to get the Activity id?

  • Activity__c should return the Id if your field is a relationship. If you need to pull in information from that object you need to use __r since you are referring to a relationship. So you should be using Activity__r.Id and Activity__c. – payamf1 Jun 19 '18 at 23:04
  • Thank you for your comment Unfortunately, using Activity__r.Id returns INVALID_FIELD error and using Activity__c return a string with the activity description – Eilon Bootel Jun 20 '18 at 06:38
  • It seems that Activity__c is a custom text field and not a relationship field. Can you please confirm? – Abhishek Sivasubramanian Jun 20 '18 at 09:26
  • Unfortunately I don't have access to the field definitions. Assuming you are right and the filed is a custom text field shouldn’t the filed definition has an id? do I have any way to full it? – Eilon Bootel Jun 20 '18 at 13:13

1 Answers1

0

Verify these

You need to get to the object definition and see the field info. You can use workbench or any other API tool if you are familiar with and get the object and field def's.

  1. Check the data type for Activity__c field. It should be a lookup/master relation. If it is not, find the field which ties to Activity object.

  2. Open the field to get the API name and use that in the query with a '__r' extension.