This might work for you... I have attached the action as well. I am looking up the vApp template based on the catalog item name which should match. I am returning the first child template as I want the individual vmTemplate as opposed to the full vApp but you could just return the vApp if that is what you need. The template management is funky in my opinion but in the end it all works. You will see the action has 2 inputs (catalog and itemName) and an output of type vCloud:VAppTemplate. Excuse the gratuitous logging but its leftover from when I was developing it. Hope this helps.
var vAppTemplates = new Array();
var vcdHost = catalog.parent.parent;
var catalogItems = new Array();
var queryService = vcdHost.getQueryService();
var expression = new VclExpression(VclQueryCatalogItemField.NAME, itemName , VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var resultSet = queryService.queryRecords(VclQueryRecordType.CATALOGITEM, params);
while (resultSet != null) {
var records = resultSet.getRecords(new VclQueryResultCatalogItemRecord());
for each (var record in records) {
if (record.catalogName == catalog.name) {
var catalogItemRef = new VclReference();
catalogItemRef.href = record.href;
catalogItemRef.name = record.name;
catalogItemRef.type = record.type;
var catalogItem = (vcdHost.getEntityByReference(VclFinderType.CATALOG_ITEM, catalogItemRef));
catalogItems.push(catalogItem);
System.log("object Type: " + System.getObjectType(catalogItem));
System.log("Record with name: " + record.name + " found");
System.log("catalog: " + record.catalog);
System.log("catalogName: " + record.catalogName);
System.log("entity: " + record.entity);
System.log("entityName: " + record.entityName);
System.log("entityType: " + record.entityType);
System.log("href: " + record.href);
System.log("id: " + record.id);
System.log("owner: " + record.owner);
System.log("ownerName: " + record.ownerName);
System.log("status: " + record.status);
System.log("type: " + record.type);
}
}
resultSet = resultSet.getNextPage();
}
if (catalogItems.length != 1) {
throw "Error retrieving catalog items. There can be only one.";
}
var entity = catalogItems[0].entity;
var vAppTemplate = vcdHost.getEntityByReference(VclFinderType.VAPP_TEMPLATE, entity);
if (vAppTemplate != null){
System.log("vApp Template: " + vAppTemplate.name + " found.");
return vAppTemplate.getChildren()[0];
}