In orchestrator 4 we had a custom built workflow and action to retrieve and return vapp names in a catalog. However sadly in Orchestrator 5 the action no longer works and being not the best at scripting I thought I would ask for some assistance
var CatalogItems = Catalog.getCatalogItems();
var vAppTemplates = [];
for (var CatalogItemIndex in CatalogItems){
var CatalogItem = CatalogItems[CatalogItemIndex];
var _VappTemplate = Catalog.parent.parent.getEntityByReference(vclEntityType.VAPP_Template,CatalogItem.entity);
VappTemplates.push(vapptemplate);
}
return VappTemplates;
The error is "Cannot read property"name" from null
Any assistance would be appreciated. Even a suggestion on a better way to do this
Here's code that does what you ask:
var catalogItems = catalog.getCatalogItems();
var vAppTemplates = new Array();
var host = catalog.parent.parent;
for each(catalogItem in catalogItems){
var entity = catalogItem.entity;
var vAppTemplate = host.getEntityByReference(VclFinderType.VAPP_TEMPLATE, entity);
if (vAppTemplate != null){
vAppTemplates.push(vAppTemplate);
}
}
The underlying problem in your code is a change described here: http://communities.vmware.com/docs/DOC-20431 - in particular, VclFinderType must now be used in place of VclEntityType.
Here's code that does what you ask:
var catalogItems = catalog.getCatalogItems();
var vAppTemplates = new Array();
var host = catalog.parent.parent;
for each(catalogItem in catalogItems){
var entity = catalogItem.entity;
var vAppTemplate = host.getEntityByReference(VclFinderType.VAPP_TEMPLATE, entity);
if (vAppTemplate != null){
vAppTemplates.push(vAppTemplate);
}
}
The underlying problem in your code is a change described here: http://communities.vmware.com/docs/DOC-20431 - in particular, VclFinderType must now be used in place of VclEntityType.
Brilliant - worked perfectly