5 Replies Latest reply on Jun 24, 2019 12:08 AM by qc4vmware

    Keep getting error when "TypeError: Cannot read property "virtualMachineID" from null (Dynamic Script Module name : getPropertiesFromVirtualMachine"

    JorgeRodriguez3006 Lurker

      I keep getting the error below when i run my workflow :

       

      [2019-06-23 12:29:13.783] [I] 1 match uuid: 50320c66-3431-ed1d-68ad-f96256cf4290

      [2019-06-23 12:29:13.786] [I] Resolved vCAC VM: vROps-ap1

      [2019-06-23 12:29:13.841] [E] Workflow execution stack:

      ***

      item: 'Get Info/Shutdown (UC1)/item3', state: 'failed', business state: 'null', exception: 'TypeError: Cannot read property "virtualMachineID" from null (Dynamic Script Module name : getPropertiesFromVirtualMachine#1)'

      workflow: 'Get Info/Shutdown (UC1)' (fd7316ef-7b9b-483a-b5df-5d5d07e45c1b)

      |  'attribute': name=VMName type=string value=

      |  'attribute': name=VMAddress type=string value=

      |  'attribute': name=VMOwner type=string value=

      |  'attribute': name=VMBsgroup type=string value=

      |  'attribute': name=VMReservation type=string value=

      |  'attribute': name=actionResult type=vCAC:VirtualMachine value=__NULL__

      |  'attribute': name=vCACIaaSHost type=vCAC:VCACHost value=__NULL__

      |  'attribute': name=errorCode type=string value=TypeError: Cannot read property "virtualMachineID" from null (Dynamic Script Module name : getPropertiesFromVirtualMachine#1)

      |  'input': name=vCenterVm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='10.20.20.50%2Cid:vm-32'&dunesName='VC:VirtualMachine'

      |  'output': name=actionResult1 type=vCAC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='31b63e72-1b20-4cc6-a61b-5af4db5f8ee3/ba9a8a14-17ae-45f4-abbe-dca45f3fc0d0'&dunesName='vCAC:VirtualMachine'

      *** End of execution stack.

       

      Flow chart is as below:

       

      Code from QCgetvCACVmFromvC action:

      //Auto generated script, cannot be modified !

      actionResult = System.getModule("org.company.mymodule").QCgetvCACVmFromvCenterVmUuid(vCenterVm) ;

       

       

      Code from show info:

      //Gets the IP Address Of the VM

      vCACVmExtendedProps = System.getModule("com.vmware.library.vcac").getPropertiesFromVirtualMachine(vCACIaaSHost,vCACVM);

      VMAddress = vCACVmExtendedProps.get("__datacollected_ipaddress");

       

       

       

       

      //Gets the name of VM

      VMHostname = vCACVM.vmDNSName;

       

       

       

       

      //Gets the owner of VM

      VMOwner = vCACCAFEFilterParam.substringOf("owners/ref",vCACCAFEFilterParam.string("user@domain.com"));

       

       

       

       

      //Gets the Business Group of the VM

      var VMBsgroup = System.getContext().getParameter("_asd_subTenantref")

       

       

       

       

       

       

       

       

      //Gets the Reservation of the VM

      var id = virtualMachine.getEntity().getProperty("HostReservationID");

       

       

      var entity;

       

       

      var idprop = new Properties( {

      "HostReservationID" : id

      });

       

       

      if (!id || id == "") throw "Error getting Reservation ID of VM.";

       

       

      if (host != null) {

      entity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "HostReservations", idprop, null);

      } else {

      var hosts = Server.findAllForType("vCAC:VCACHost");

      System.debug("hosts: " + hosts);

      for each (var host in hosts) {

      try {

      entity = vCACEntityManager.readModelEntity(host.id, "ManagementModelEntities.svc", "HostReservations", idprop, null);

      } catch (e) {

      throw "Error reading model entity.";

      }

      }

      }

       

      VMReservation = entity.getInventoryObject();

       

       

       

       

       

       

       

       

       

       

       

       

      //Return Values

      Server.log("Hostname : " + VMHostname);

       

       

      Server.log("IP Address : " + VMAddress);

       

       

      Server.log("Owner : " + VMOwner);

       

       

      System.log("Business Group name: " + VMBsgroup);

       

       

      System.log("Reservation of VM: " + VMReservation);

       

       

       

       

       

      I'm not sure what the issue might be?