7 Replies Latest reply on Dec 8, 2018 8:16 AM by cjoshi


    cjoshi Novice

      I am executing a workflow via vRA as a Resource Action. The workflow succeeds via vRA on a VM unmanaged by vRA. However on trying to execute the workflow on a vRA provisioned item it fails with a TypeError. I am confused and unable think of a logical answer. I guess the custom action called via vRA on a provisioned vRA item is setting the context to something different than what is being expected hence it works on a vCenter managed VM and not a vRA managed VM (both via vRA).


      Any help/pointers would be appreciated. Mentioned below is the error stack:


      [2018-12-07 23:58:27.166] [E] (bar.foo.vro/getExtendVmDiskConfigSpec) Error in (Dynamic Script Module name : getExtendVmDiskConfigSpec#3) TypeError: Cannot read property "1" from null

      [2018-12-07 23:58:27.193] [E] Workflow execution stack:


      item: 'Extend VM Disk/item1', state: 'failed', business state: 'null', exception: 'TypeError: Cannot read property "1" from null (Dynamic Script Module name : getExtendVmDiskConfigSpec#3)'

      workflow: 'Extend VM Disk' (1b870d49-6e7d-4abb-9dae-66349fbea6b6)

      |  'attribute': name=actionResult type=Array/string value=__NULL__

      |  'attribute': name=task type=VC:Task value=null

      |  'attribute': name=progress type=boolean value=null

      |  'attribute': name=pollRate type=number value=null

      |  'input': name=vm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='sa-vcsa-01.vclass.local%2Cid:vm-107'&dunesName='VC:VirtualMachine'

      |  'input': name=diskInfo type=string value=Hard disk 1   [ Existing disk size : 0.75 GB ]

      |  'input': name=sizeGb type=string value=2

      |  'attribute': name=__asd_requestedBy type=string value=Cloud-Op01@vclass.local

      |  'attribute': name=__asd_tenantRef type=string value=vsphere.local

      |  'attribute': name=__asd_targetResourceInternalId type=string value=90307997-3b80-4799-8aa0-781767b1bd23

      |  'attribute': name=__asd_catalogRequestId type=string value=f3203582-1151-4bd6-8da6-3e53036696a7

      |  'attribute': name=__asd_subtenantRef type=string value=dfbbdff7-c277-43a9-b6c3-b2edb474a10f

      |  'attribute': name=__asd_requestedFor type=string value=Cloud-Op01@vclass.local

      |  'attribute': name=__asd_targetResourceId type=string value=d17069f1-341c-417f-a300-5dfc3e9ebf3e

      |  'attribute': name=__asd_targetResourceTypeId type=string value=Infrastructure.Virtual

      |  'attribute': name=__asd_targetResourceProviderId type=string value=39338711-941f-4b29-9aa9-586be5661faa

      |  'no outputs'

      *** End of execution stack.


      Also the workflow works as expected /correctly when directly called via vRO.


      Setup details: vRA 7.4 with Embedded vRO, vSphere 6.5.

      I am able to browse the vCenter and vRA inventroy via the vROso I guess the plugins are working as expected.



      Regards Shekhar

        • 1. Re: TypeError
          daphnissov Guru
          Community WarriorsvExpert

          Without looking at some code it's impossible to tell why you're getting this error.

          • 2. Re: TypeError
            cjoshi Novice

            Adding some more information:


            Following is the workflow. Its a disk extend workflow based on the vRealize Orchestrator – Extend Virtual Disk Workflow – Part 1 of 2 | vBombarded blog article.

            I have slightly modified the workflow from a learning perspective. Created 2 Action Items, one to fetch the Disk Info and other to create VMConfigSpec. In the above depicted workflow the VM reconfigure task.


            There is a vRO dynamic action to populate the (existing) disks dropdown on the form that is working as expected. What's not working is the submit and that too only for vRA managed items. Relevant code mentioned below:


            vRO Action to generate the VMConfigSpec

            -- cut --

            var devices = vm.config.hardware.device;

            var match = diskInfo.match(/\w+\s+\w+\s+(\d+)\s+.+?:\s*(\d+)\s*GB/);

            var newDiskSizeKb = newDiskSizeGb * 1024 * 1024;

            var diskName = 'Hard disk ' + match[1];


            configSpec = new VcVirtualMachineConfigSpec();

            configSpec.changeVersion = vm.config.changeVersion;


            for (i in devices){

                if (devices[i].deviceInfo.label == diskName){

                    var disk = devices[i]

                    System.debug("Found '" + disk.deviceInfo.label + "'");




            var deviceChanges = new Array();

            var deviceChange = new VcVirtualDeviceConfigSpec();

            deviceChange.operation = VcVirtualDeviceConfigSpecOperation.edit;

            deviceChange.device = disk;

            deviceChange.device.capacityInKB = newDiskSizeKb;


            configSpec.deviceChange = deviceChanges


            var actionResult = [];



            return actionResult;

            -- cut --


            vRO Action to fetch disk information

            -- cut --

            var devices = vm.config.hardware.device;

            var actionResult = [];


            for (i in devices){

                if (devices[i].DeviceInfo.Label.indexOf('Hard disk') >= 0){

                    var sizeGb = devices[i].capacityInKB / 1024 / 1024;

                    var diskInfo = devices[i].deviceInfo.label + "   [ Existing disk size : " + sizeGb + " GB ]";




            return actionResult;

            -- cut --


            Reconfigure VM Scriptable task

            -- cut --

            var configSpec = actionResult[0];

            if (configSpec != null && (configSpec instanceof VcVirtualMachineConfigSpec) == false) throw "configSpec must be of type 'VcVirtualMachineConfigSpec'";


            task = vm.reconfigVM_Task(configSpec);

            -- cut --

            • 3. Re: TypeError
              iiliev Champion
              VMware EmployeesCommunity Warriors



              This error is happening because the regular expression matching does not return what you are expecting. Check the following lines


              var match = diskInfo.match(/\w+\s+\w+\s+(\d+)\s+.+?:\s*(\d+)\s*GB/);
              var newDiskSizeKb = newDiskSizeGb * 1024 * 1024;
              var diskName = 'Hard disk ' + match[1];


              So, on the first line you are trying to match diskInfo value with some regular expression, and you assign the result from this matching to the match variable. Then, on the third line, you are accessing the second element from the match variable array, and you get the error because either the match variable is null or it is an array with less than 2 elements.


              To find the reason for matching not working, you need to provide the value of diskInfo value at this point. Probably it is some string value that has different format than what the regular expression expects. You can try to dump diskInfo value using System.log(diskInfo) to see what is its value and then we can reason why this value does not match the regular expression.

              1 person found this helpful
              • 4. Re: TypeError
                cjoshi Novice

                Hi Ilian and others,


                Before I go further, let me just say thanks to everyone on this community. It was late yesterday and I was sleepy/frustrated hence did not do that with my first question/reply. I have learnt much of orchestrator (and many other VMware products) by looking at questions and answers posted on this community. Back to question :-).


                If regular expression been the problem then the workflow would not have worked directly even from the orchestrator. As hinted by you I am trying this with a simple workflow and only dumping the values. I am now testing a similar user interaction (vRA + vRO) but with simpler workflow. What I observe is the following:


                vRO form has 3 fields: vmObject (search/list box), hardDiskList (dynamic drop-down list generated by vRO action via 'Predefined list of elements'), sizeInGb (standard text box). This works as expected from vRO.


                vRA custom action form (default auto generated form) has 2 input fields:


                hidden vm field (hidden because custom vRA action invoked in that context)

                hardDiskList drop-down  (gets input from orchestrator workflow, works as expected)

                sizeInGb textbox (on vRO this is a string object).


                Now when I call this via vRA, I can reads values from both vm & hardDiskList but sizeInGb is set to null. What is it that I am doing incorrect that this textbox sets the value to null?


                On a side question, how do you insert code here in the question/reply as a markup with code formatting?



                Regards Shekhar

                • 5. Re: TypeError
                  cjoshi Novice

                  Solved. Looks like there is bug in the vRA presentation layer. If the having multiple fields where some fields are getting dynamic values from an vRO action, the other input fields may fail to send data to vRO.


                  In case someone comes searching for the issue, the fix: create a new form page and separate data based on the type.

                  • 6. Re: TypeError
                    daphnissov Guru
                    vExpertCommunity Warriors

                    If on vRA 7.4, make sure you've applied the latest available hotfix here.

                    1 person found this helpful
                    • 7. Re: TypeError
                      cjoshi Novice

                      Thanks. Sure I will check that with the production deploymentand on my test bed where I was trying it.