Automation

 View Only

vRA Custom Form Dropdowns with External Source Error

  • 1.  vRA Custom Form Dropdowns with External Source Error

    Posted Nov 08, 2022 03:46 PM
      |   view attached

    Hi all,

    I have a strange problem with action and drop-down menu in vro 8.6.
    I created an action "getTagsFromCategoryName" that return a String/Array with all the tags present in a selected tagCategory ( another drop-down menu populated with action ). 
    At each run of the workflow, I got a red banner with error : "There was a problem invoking action com.bper/getTagsFromCategoryName;" even if all the fields are correctly populated.
    Can someone help me with this error ?

    Thanks in advance
    Pietro

    getTagsFromCategoryName code is:

    //var vapiEndpoints = Server.findAllForType("VAPI:VAPIEndpoint");
    //var endpoint = vapiEndpoints[0];

    if (vapiEndpoint == null) { throw "'vapiEndpoint' parameter should not be null" }
    if (tagCategoryName == null) { throw "'tagCategoryName' parameter should not be null" }

    System.debug("VAPI endpoint selected: " + vapiEndpoint.endpointUrl)
    var client = vapiEndpoint.client();

    var outputTags = new Array()
    var category = new com_vmware_cis_tagging_category(client)
    var categories = category.list()
    var tagging = new com_vmware_cis_tagging_tag(client)
    var tags = tagging.list()

    // Iterate through tag categories to find the category specified in categoryName
    var categoryId = ""
    for each (var tagCat in categories){
      if (category.get(tagCat).name == tagCategoryName ) {
        categoryId = category.get(tagCat).id
        System.debug("Found tagCategory: " + tagCategoryName + " with ID: " + categoryId)
        break
      }
    }

    // Iterate through tags to find the tags that belong to the categoryName and add them to the outputTags array
    for each (var tag in tags){
      if (tagging.get(tag).category_id.toString() == categoryId) {
        outputTags.push(tagging.get(tag).name)
        System.debug("Found tagName: " + tagging.get(tag).name)
      }
    }

    if (outputTags.length < 0){
      System.log("No tag found in " + tagCategoryName)
    }else {
        System.log("Tags found: " + outputTags.sort())
    }

    client.close();
    return outputTags.sort()