I would like to filter the results from an Anguila WhereUsed query to return only Components based on a certain schema. But, when I specify the ItemType or BasedOnSchema filters it returns no results. Why do the filters not work?
The code is based on Jaime's solution here: WhereUsed with Tridion Anguilla GUI Framework
Update: I have included my attemp to use a callback on the load method, but not sure if it is correct...
function ShowWhereUsed(c){
// Begin Where Used
//Get the item:
$item = $models.getItem(c.getId());
//Define a filter:
$filter = new Tridion.ContentManager.ListFilter();
$filter.columns = $const.ColumnFilter.DEFAULT;
$filter.conditions.InclLocalCopies = true;
//$filter.conditions.ItemTypes = 16;
//$filter.conditions.BasedOnSchema = "tcm:174-277968-8"; // specifying a schema returns no results
console.log('Before Load');
//Get the list:
$list = $item.getListUsingItems($filter, false, false);
// register onload event for this item
$evt.addEventHandler($list, "load", onItemLoaded);
// call to load the item
$list.load($list.isLoaded(true));
//$list.load(true);
console.log('After load');
}
// define onload delegate method
var onItemLoaded = function onItemLoaded() {
console.log('onItemLoaded start');
$evt.removeEventHandler(this, "load", onItemLoaded);
// continue your code here
var listXmlDoc = this.getXmlDocument();
console.log(listXmlDoc);
ShowWhereUsedDisplayLinks(listXmlDoc);
console.log('OnItemLoaded end');
};
With the below code (workaround, prefer to use above) I can get only Components, but then I also need to test for the Schema:
var tridionItem = $models.getItem(compUri);
console.log(tridionItem);
var itemType = tridionItem.getInfo().ItemType;
if (itemType == $const.ItemType.COMPONENT)
{
// Test for Schema here and show
}