• Westec Intelligent Surv.
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies

I'm trying to get a list of field histories for an Opportunity, including who made the change and when. I see the CreatedBy and CreatedDate fields for the OpportunityFieldHistory entity in my WSDL, and therefore I can also see the properties in my generated Salesforce domain. However, when I try to specify them as fields to select on or filter by in the query, I get an INVALID_FIELD error that the table doesn't have these fields. The documentation for this table does not include the fields. The remaining info is useless to me and my users without these two fields. My WSDL was generated against version 20.0 of the API. What's going on here?

I tried this in the Apex Coding board, the solution was invalid. Basically, I need a single query, executable using the API, that will return all NoteAndAttachment items that would normally show in the Notes And Attachments section of an Account page in the Web UI. This includes not only N&A that are attached to the parent, but also those that are attached to any Case, Opportunity, or Contact that is related to the account. Salesforce itself seems to have no problem getting that information, but between SOQL limitations and restrictions on the data model, I have yet to find a satisfactory solution.

 

Here's what I have so far:

 

 

SELECT Id,
(select Id, Title, IsNote from NotesAndAttachments),
(select Id, Title, IsNote from Contacts.NotesAndAttachments),
(select Id, Title, IsNote from Cases.NotesAndAttachments),
(select Id, Title, IsNote from Opportunities.NotesAndAttachments)
FROM Account a WHERE Id = '{0}'

 

 

The {0} is for use with a .NET String.Format; it'll be the account ID I'm pulling records for. This particular query fails with the following exception:

 

 

System.Web.Services.Protocols.SoapException : INVALID_FIELD: 
(select Id, Title, IsNote from Contacts.NotesAndAttachments),
                               ^
ERROR at Row:3:Column:48
Didn't understand relationship 'Contacts' 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.

 

These are all basic, system-defined relationships, and it didn't recognize the singular "Contact" either, so I'm at a loss.

 

 

Other solutions have involved semi-join sub-selects (there's a limit of two and you can't combine them with OR so no dice), nested subqueries (can't subquery more than one level deep from the root), etc. I'm really at my wits end with this query language's limitations; no UNION, limited subqueries, limited subquery depth, and the NoteAndAttachment entity cannot be queried directly. There simply has to be a way to get these records the same way they're shown in the website, but I'm being frustrated at every turn..

 

I need a SOQL query that will retrieve a result set similar to what you get in the Notes And Attachments section of an Account. This list includes not only all Notes And Attachments with the Account itself as the parent, but also for all Cases, Opportunities and/or Contacts related to the Account. With the NoteAndAttachment entity not queryable directly, and with no UNION clause available, I don't even know where to begin writing a single all-includive query.

I'm using the standard Case object (we have some custom fields but that doesn't appear to be the problem). The Case has a linked subquery to its Comments, replicated in the SOAP API as CaseComments. My test case for upserting records is to query() for one by case number, change something, and upsert that record again. When I do so, I get an INVALID_FIELD error stating that CaseComments doesn't exist on the Case table in the cloud. Of course it doesn't exist, and the API should know better. Or maybe I'm not telling it something. Help?

 

UPDATE: tried setting the property to null; didn't work. The error in that case is "INVALID_TYPE: Must send a concrete entity type."

I need a SOQL query that will retrieve a result set similar to what you get in the Notes And Attachments section of an Account. This list includes not only all Notes And Attachments with the Account itself as the parent, but also for all Cases, Opportunities and/or Contacts related to the Account. With the NoteAndAttachment entity not queryable directly, and with no UNION clause available, I don't even know where to begin writing a single all-includive query.