VMware Cloud Community
vStorm
Contributor
Contributor
Jump to solution

Retrieve Catalog vapps

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

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
2 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

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.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
vStorm
Contributor
Contributor
Jump to solution

Brilliant - worked perfectly

0 Kudos