VMware Aria Automation Orchestrator

 View Only
  • 1.  JavaScript comparing two arrays. include() function is not present?

    Posted Jul 03, 2025 12:04 PM

    I'm not well-versed in JavaScript, but it looks like some common JavaScript features aren't available in Aria Automation's implementation. 

    Take this snippet in a JavaScript action:

    var list1 = ['Server1','Server2','Server3'];
    System.log(Array.isArray(list1));
    System.log( list1.indexof('Server1') );
    System.loog( list1.includes('Server1') );

    On line 1, variable "list1" is initialized as an array of Strings.

    On line 2, we confirm that "list1" is indeed an array. It is; this line returns True.

    On line 3, we get the index of an element. This line errors out with "cannot find function indexof". 

    If we comment out line 3, then line 4 also errors out with "cannot find function includes". 

    Why are these lines of code failing? Have I formatted something incorrectly? Or is there something unusual about Automation Orchestrator's implementation of JS?



  • 2.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted Jul 04, 2025 03:23 PM

    Your question is very valid. vRO upto 8.18.x uses Rhino Engine 1.7R4 which loosely implements JavaScript 1.7 and ECMAScript 5.1+ and it doesn't have includes() function. However indexOf() is supported. The only problem in your code is the way you calling indexof instead of indexOf.

    Read more here:

    https://cloudblogger.co.in/2022/12/02/inside-vros-javascript-engine-rhino-1-7r4-cb10102/

    https://mozilla.github.io/rhino/compat/engines.html -> Look for 1.7R4




  • 3.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 29 days ago

    Thanks for the information, and that's a great blog. I'm looking at your other posts now. 

    That's a shame less than half of the ECMA standard is supported. I'm already a novice with JavaScript, and now I'm entering a minefield of missing features. :(

    Given that includes() is not available, how would you write a snippet comparing two arrays? Here's a sample of the code I tried to write. list1 has 5 items. 2 of the items ('server3' and 'server5') are not in list2. I want to create a new array with items that are in list1 but not list2 (then assign that to a variable in a workflow). 

    This should work in vanilla JS. How can I adapt it to work in Rhino/vRO?

    var list1 = ['Server1','Server2','Server3','Server4','Server5'];
    var list2 = ['Server1','Server2','Server4','Server6','Server7'];
    var different = new Array();

    list1.foreach((element) => {
        if (!list2.includes(item)){
            different.push(item);
            }
        });




  • 4.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 28 days ago

    Today, I think AI editors like ChatGPT etc would be the best bet for converting ES6+ code to ES5 vRO compatible code (looked for my transpilers but none suited my\your requirement). Also, ask the editor to change console.log() with System.log(). Additionally, avoid forEach() in your code as it is deprecated. 



    ------------------------------
    Mark as Resolve if it answers your query. Thanks. Helps me collect points.

    M
    ------------------------------



  • 5.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted Jul 04, 2025 03:23 PM

    I would like add further that in VCF 9, Orchestrator uses Rhino Engine 1.7.15 which supports 46% ECMAScript 2015 where as 1.7R4 only supported 7%. There is going to be huge improvements in overall features and efficiency. I know that arrow functions are now working but no let support yet.



    ------------------------------
    Mark as Resolve if it answers your query. Thanks. Helps me collect points.

    M
    ------------------------------



  • 6.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 29 days ago

    What language is recommended for custom Actions/Workflow in Orchestrator 8.18? I'm competent in PowerShell/PowerCLI and Python. But I've made most of my actions in JavaScript, just because the built-in actions are all in JavaScript. It appears the API for JavaScript has more options than PowerShell, Python, or Node.js. Is that correct?




  • 7.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 28 days ago

    With Polyglot (Python, PS and Node.js), you still mostly rely on REST APIs to even communicate with vRA or vRO. JavaScript runtime is inheritably exposed to vRO Scripting SDK which means there are JavaScript classes for almost everything. It even supports vRO Plugins, means even more JS classes to work with.
    With Polyglot, you could still access the vRO filesystem, work with some vRO variable types like MimeAttachment, Array etc. And the best part, you can import any 3rd party module using Action environments (you cant do that with JavaScript runtime). So, it's all drill down to the developer what he wants and what suits his requirements.

    https://cloudblogger.co.in/2022/07/20/getting-started-vrealize-orchestrator-script-environments-cb10098/
    https://cloudblogger.co.in/2024/04/10/simplest-way-to-generate-bearer-token-in-orchestrator-for-aria-automation-cb10135/
    https://cloudblogger.co.in/2025/04/24/comparative-analysis-of-orchestrator-polyglot-approaches/
    https://cloudblogger.co.in/2025/06/22/how-to-use-3rd-party-polyglot-modules-as-native-javascript-class-in-vcf-orchestrator/

    Here are some links that might help you in understanding the Polyglot concepts.



    ------------------------------
    Mark as Resolve if it answers your query. Thanks. Helps me collect points.

    M
    ------------------------------



  • 8.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 11 days ago

    @Mayank Goyal:

    > in VCF 9, Orchestrator uses Rhino Engine 1.7.15

    How were you able to determine the new version for Rhino in VCF Automation/Orchestrator?




  • 9.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 11 days ago

    Check out my detailed blog for your reference on enabling and getting Rhino engine version in vRO.

    https://cloudblogger.co.in/2025/07/25/enable-access-to-java-classes-in-javascript-code-and-get-rhino-engine-javascript-versions/



    ------------------------------
    Mark as Resolve if it answers your query. Thanks. Helps me collect points.

    M
    ------------------------------



  • 10.  RE: JavaScript comparing two arrays. include() function is not present?

    Posted 5 days ago
    Edited by Broadcom Platform Admin 3 days ago

    You push the difference to a new array. Why? Do you wanna compare the arrays or do you wanna find the difference?

    One way to compare the arrays could be done with a simple for loop, and then return a true / false as in "compareA". An alternative is to convert the JS object into a JSON and compare them, which will also covers multidimensional arrays or objects, "compareB".  For the simplicity and flexibility I would go for B.  

    var list1 = ['Server1','Server2','Server3','Server4','Server5'];
    var list2 = ['Server1','Server2','Server4','Server6','Server7'];
    //var list2 = ['Server1','Server2','Server3','Server4','Server5'];

    System.log(compareA(list1, list2));
    System.log(compareB(list1, list2));
    function compareA(array1, array2) {
       
        if(array1.length != array2.length) {
            return false;
        }

        for (var i = 0; i < list1.length; i++) {
            if(array1[i] != array2[i]) {
                return false;
            }
        }
        return true;
    }

    function compareB(array1, array2) {
       
        if(JSON.stringify(list1) == JSON.stringify(list2)) {
            return true;
        }
        return false;
    }