0
Answered

Executing javascript (question and ideas)

playsted 2 years ago in Server / Execution • updated by Pieter 1 year ago 6

What javascript execution engine is used? I have having issues with scripts as some functions are not working properly.


Problem 1:

"testString".endsWith("g");

is valid javascript and works with node and browsers. This should return true.


However running this as a script in a workflow results in an error due to it not being a function.


Problem 2:

If I use variables in the script the strings are not escaped.

Variable:

[[testPath]] = "C:\test"

In script:

"[[testPath]]" => "c:est"



Suggestions:


I think it would be very powerful to use node.js as the javascript execution as it is so widely used. Edge.js is a c# library that allows node to easily be executed from .Net. I haven't researched it much but may be an option.


As far as escaping strings you could predefine them all on a javascript object that the script runs in. Instead of using [[varName]] we could just use $ww.varName if we use $ww as the example object that Warewolf populates. This would take care of string escaping problems and even allow complex objects to be manipulated as expected while coding javascript.


execution server workflow

Answer

Answer
Under review

Hi Playsted,


We will look into updating the library in a coming version.


Thanks for the suggestion and thinking on this we will definitely consider it.

Answer
Under review

Hi Playsted,


We will look into updating the library in a coming version.


Thanks for the suggestion and thinking on this we will definitely consider it.

Searching answer
Genie via Jira 1 year ago
Sanele via Jira 1 year ago

Please check the attached (Scritps used to test the Include functionality)
rubySource.rb pythonFile.py endsWith.js startsWith.js

Steps performed:
Using JavaScript

  1. Test1
  • On the Script tool's _Script Syntax _ I typed return "testString".endsWith("g");
  • Execution results to an Error
  • I clicked include file and included (endsWith.js)
  • Execution result returns "True"

You can also attach multiple scripts
Repeat #Test1
now, type: return "testString".startWith("t");

  • Execution results to an Error
  • I clicked include file and included (startWith.js)
  • Execution result returns "True"
    --------------------------------------------------------------------------------------------

Same procedure applied when testing the rest of the script types (The other script types I used Numbers to test a GreaterThan function)

Sanele via Jira 1 year ago

Steps performed testing the Escape Charecters Functionality
Using JavaScript

  1. Test1
    Assign [[Value1]] = "C:\test" (including the quotation marks)
    On the Script tool's Escape sequence in variables the CheckBox is ticked
    On the Script tool's _Script Syntax _ I typed return "the path is : " + [[Value1]]
    Execution result is "the path is : C:\test"
  1. Test2
    Untick Escape sequence in variables
    Execution result is "the path is : C: est"
  1. Test3
    Change the script content to include more escape sequences
    Tick Escape sequence in variables
    I typed return "the path is \n " + [[Value1]]
    Execution result is "the path is
    C:\test"
  1. Test4
    Change the script content to include more escape sequences
    UnTick Escape sequence in variables
    I typed return "the path is \n " + [[Value1]]
    Execution result is "the path is
    C: est"