SchemaTitleCriteria yield no results in SDL Tridion Broker Query - tridion

I have a simple SDL Tridion 2011 SP1 Broker Query to retrieve a list of Component URIs. All of my Components are embedded on Pages, and not using Dynamic Component Templates. The following code returns 50 results (which is to be expected). One of which is the URI tcm:123-456-16.
List<Criteria> criteria = new List<Criteria>();
criteria.Add(new ItemTypeCriteria(16));
criteria.Add(new PublicationCriteria(337));
Query query = new Query(CriteriaFactory.And(criteria.ToArray<Criteria>()));
String[] results = query.ExecuteQuery();
The Component tcm:123-456-16 is based on a Schema with the name “News Portal”. I would like to add additional criteria to my query so that I only get items based on that Schema, so I tried the following code:
List<Criteria> criteria = new List<Criteria>();
criteria.Add(new ItemTypeCriteria(16));
criteria.Add(new PublicationCriteria(337));
criteria.Add(new SchemaTitleCriteria("News Portal"));
Query query = new Query(CriteriaFactory.And(criteria.ToArray<Criteria>()));
String[] results = query.ExecuteQuery();
This returns no results at all. I have double checked my Schema name. Is this response expected? Does the SchemaTitleCriteria require the Components to be published as Dynamic Component Presentations. Any advice would be greatly appreciated.

Yes and No on DCPs. You don't need to have all your components published as Dynamic Component Presentations (DCPs). We noticed the same and observed that if you don't publish at least one DCP based on the schema, the schema title does not get published into Schemas table of the Tridion Broker DB (not sure it is by design). Once you publish one DCP based on the schema, the schema title is stored and subsequent queries work, but until you publish that first one you will not get any.
However in practical scenario, you do broker queries to get the dcps so you should not see this behavior except a mistake or someone missed it.

Why would the component be present in the first result set, but not in the second?
I suspect this is unintended behaviour and worth raising with SDL.
To fix it you'll need to use ItemSchemaCriteria instead of SchemaTitleCriteria and obtain the components based on the schema ID, rather than the schema title.
To use the SchemaTitleCriteria I should imagine you need to have at least published one component based on the news portal schema alonside a dynamic component template so that the content delivery database contains the schema title information.

Related

How to get column wise data using AEM query SQL2?

I am running a following AEM Query SQL2 on CRXDE and it is successfully returning me nodes as per following given screenshot.
But I need data like column wise (jcr properties) like SQL table. Can anyone help me if it is possible.
You can't do this with CRXDE. It shows only the path of the most outer node, even if the query has multiple columns. This is especially limiting, if your query uses joins.
In your case I would recommend the Query Builder. It has a totally different syntax, but the JSON or XML result contains all data you need.
I don't know other tools. As AEM developer I usually write a quick & dirty servlet, and let it run on my local instance (with production content)
Query Builder Debugger
http://localhost:4502/libs/cq/search/content/querydebug.html
Example Query
path=/content/we-retail/language-masters/en/experience
property=sling:resourceType
property.value=weretail/components/content/image
p.hits=full
p.nodedepth=2
Resulting JSON Query
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
http://localhost:4502/bin/querybuilder.json?p.hits=full&p.nodedepth=2&path=%2fcontent%2fwe-retail%2flanguage-masters%2fen%2fexperience&property=sling%3aresourceType&property.value=weretail%2fcomponents%2fcontent%2fimage
Documentation
https://docs.adobe.com/content/help/en/experience-manager-64/developing/platform/query-builder/querybuilder-api.html
In your case especially see: Refining What Is Returned
You will find much more with Google, as the Query Builder is pretty old in AEM/CQ.

The required QueryBuildDataSource was not found in the Query associated with the FormDataSource

I've extended the SalesTableListPage to include a new column taken from a display method on CustTable now my users are getting the error:
The required QueryBuildDataSource was not found in the Query associated with the FormDataSource . The QueryBuildDataSource should have the same name and table ID as the FormDataSource.
To gain access to the display method I had to:
Add CustTable to the SalesTableListPage Query
Re-Select the SalesTableListPage Query on the Data Sources node of the SalesTableListPage Form.
Add a new StringEdit on the grid and set it to CustTable CityName_BR
I can't replicate this error with my admin or my non-admin user and I don't understand where this error comes from.
One post says that if you have a Query on the menu item that opens the Form then that query needs the same data sources as the query on the form. But I don't have a query on my menu item
Other suggestions state that I need to add the new data source "in the Table related queries". I am unaware of such a setting in AX 2012
Other suggestions refer to queries written in code. mine are AOT queries
Update: It seems the reason I wasn't getting the error was that I had the CueGroup EPCustRelatedInfo or just CustRelatedInfo collapsed. When I unfold this part I am getting the error as well.
Resolving that Cue Group has led me to several menuitems with queries attached. The culprit seems to be the SalesTableListPageOpen menu item and query of the same name (which references the query I have changed).
I am however still confused as to how to actually fix the error since the SalesTableListPageOpen query just says Composite Query\SalesTableListPage. Unsetting/resetting the referenced query, restoring and re-compiling the query has not had any effect...
I think one of your suggested solutions is probably correct. Just investigate the query though and you should be able to figure out what's happening.
At the bottom of \Classes\SalesTableListPageInteraction\initializeQuery just put:
info(_query.toString());
Then open the menus All sales orders and Open sales orders and you'll see the query differences. Then repeat opening various menu items with different users and see what results.
You may need to move the location of the info line, but the concept is there.

Where to get the URL data from in this trigger

I was having old tridion 2009 trigger, this is the code:
CREATE TRIGGER My_TABLE ON [ITEMS]
FOR INSERT
AS
INSERT INTO My_TABLE(ACTION, PUBLICATION_ID, ITEM_REFERENCE_ID, ITEM_TYPE, LAST_PUBLISHED_DATE, URL, SCHEMA_ID)
SELECT 'ADD', PUBLICATION_ID, ITEM_REFERENCE_ID, ITEM_TYPE, LAST_PUBLISHED_DATE, URL, SCHEMA_ID
FROM inserted
In tridion 2009 URL and SCHEMA_ID where part of ITEMS table, however when we upgrade to Tridion 2011 SP1, these columns do no longer exist in the ITEMS table.
SCHEMA_ID is moved to the COMPONENT table, I am little curious how to get the URL for each type of items (page, component etc. do we need to use link_info table to get url)
Just let me know which table would be used to get the URL as it was in ITEMS table before
Thanks.
There's a reason why Database details are never documented: SDL does not support access to that data at this level.
You have a pretty rich API to retrieve the data you need whenever you need it, and this allows SDL to constantly improve the database layer without having to worry about implementation support.
In your case, it might help if you explain a few things here...
Which Database is this? Reading the column names it looks like it's a Content Delivery database?
Why do you want to store the published URL? It's already there.
In case it's not clear yet, you should use the Linking classes to get the URL, not the LINK_INFO table. A properly setup environment will cache these values so you don't need to worry about any database impact. If this is not yet enough, and you really do need a custom table with custom values, then consider using a Deployer Extension that populates your table(s) as needed.

Tridion 2011 SP1 CD API - retrieve content tagged with keyword

We're designing schemas for content that we want to retrieve via the CD API based upon a Keyword field. From an API point of view, I'm wondering if it makes a difference if this field is a Content field or a Metadata field:
Looking at the API docs, there's a TaxonomyKeywordCriteria available to query all content which are related to a specific Keyword which I can pass to Query object.
This only applies to Keyword fields in custom metadata, correct?
There's also the TaxonomyRelationManager class which has a GetTaxonomyContent method as well as the GetTaxonomyComponentPresentations method in the ComponentPresentationFactory class.
These would apply to Keyword fields in content or custom metadata?
Is there any performance difference between the API calls to be aware of?
The Keyword field is important from an editorial point of view so I'm leaning towards creating it as content field rather than it being "hidden" under the metadata tab.
Cheers
EDIT
Initial (quick & dirty!) tests show TaxonomyRelationManager is x10 quicker than ComponentPresentationFactory, which is x1.5 quicker that Query.
However ComponentPresentationFactory contains actual content rather than just TCM IDs which could be more useful in my scenario.
Normal content fields don't automatically get published to the broker. Keyword fields are the exception to this: a keyword field is automatically metadata even if it's on the content tab.
I see you've already answered the performance part of your question yourself.
As far as I'm aware only Metadata fields get published to the Broker, Content fields don't. So if you need to query against the keyword field it would need to be a Metadata field.

umbraco and custom system table

I have the following scenario:
My website db has a system table called "Companies", which includes an id field, companyName field, and companyImageUrl field.
How do I set up an umbraco document type for adding entries to this table ?
Maybe I shouldn't use a custom table at all ?
Thanks.
As far as I know, Umbraco doesn't support what you want to do out of the box (mapping a document type to a table that isn't part of the umbraco core).
One approach that might work is to create an action handler that syncs a Company doc type to your table when creating a node of that type.
It's a bit of a hack though. I've found that I've very rarely needed to create custom tables. What exactly are you trying to do with it? My guess is that you don't really need it and would be better off working with a doc type instead. Umbraco provides a variety of ways to get and act upon doc types from within custom C# code (check out the umbraco.NodeFactory namespace). You'll also get the added benefit of being able to easily interact with these nodes from XSLT/Razor.

Resources