You need to sign in to do that
Don't have an account?
Clay Loveless
Solutions, Categories and SOQL: how to get Solutions in a Category?
I'm new to Apex, SOQL and the entire Salesforce world, so please forgive me if this is a silly question.
I'm working with a partner who has grouped their Soultion objects into categories. I can see these groupings with no problem in the UI of the Salesforce dashboard (Solutions tab), but cannot for the life of me conjure up the correct SOQL query to get a list of Solutions for a particular category.
For example, here's a query that seems reasonable based on what I've read in the documentation. Result *should* be an array of SolutionNames and SolutionNotes for Solutions in the category 'Foo'.
Code:
Instead, I am treated to this error: INVALID_TYPE: Didn't understand relationship 'CategoryNode' in FROM part of query call. If you are attempting to use a custom relationship ...
For something as straightforward as "give me a list of Solutions within Category 'Foo'", I feel like I'm having a harder time than I should be.
What obvious thing am I missing? :)
Thank you!
I'm working with a partner who has grouped their Soultion objects into categories. I can see these groupings with no problem in the UI of the Salesforce dashboard (Solutions tab), but cannot for the life of me conjure up the correct SOQL query to get a list of Solutions for a particular category.
For example, here's a query that seems reasonable based on what I've read in the documentation. Result *should* be an array of SolutionNames and SolutionNotes for Solutions in the category 'Foo'.
Code:
SELECT SolutionName, SolutionNote, (SELECT CategoryNode.MasterLabel FROM CategoryNode WHERE MasterLabel = 'Foo') FROM Solution
Instead, I am treated to this error: INVALID_TYPE: Didn't understand relationship 'CategoryNode' in FROM part of query call. If you are attempting to use a custom relationship ...
For something as straightforward as "give me a list of Solutions within Category 'Foo'", I feel like I'm having a harder time than I should be.
What obvious thing am I missing? :)
Thank you!
see this diagram
you will need to construct a query that combines tables using category data objects which have category id and solution id.
normaly i use eclipse and the schema viewer to construct SOQL statements , do you have eclipse installed?
the self service portal allows you to search solutions by category (and uncategorized) and this functionality has proven impossible so far for me to emulate in vb.net. i keep getting the same errors as above even though apex explorer shows a seemingly valid child relationship. :o(
please be a little more specific, as i am not understanding your suggestion. (i'm new to soql...)
we're using apex explorer so it would be grand if you could scribble a working query to pop in there to see what you are talking about.
thanks! and regards,
This thread is a bit old but I recently struggled with something similar and thought I'd share the solution I found.
There is a relationship between CategoryNode, CategoryData, and Solution which is documented here.
However, despite the supposed relationship, a query such as the following does not work:
Instead, the only thing that worked for me was to use the IN clause with a sub query to filter the results:
This seems to perform much better (and is definitely more efficient) than having to pull back CategoryData results, loop through each one, and perform another query to get Solution objects.