Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
736 views

reponse scriptlet string method unavailable

Jump to solution

I got this scriptlet:

var myresults = new String();
var myresults = scriptletContext.get("results");
var resp = myresults.includes("True");
if ( resp ){
 scriptletResponse = "success";
}
else {
 scriptletResponse = "failure";
}

I'm trying to evaluate the response I get from an operation a string "True" or "False" ( that is filtered out of a XML response)

and I always get this error, the erro is always when using .includes() , it seems that the method is available.

I either need it to work or something that does the same ( return true/false when comparing 2 strings)

2017-12-20 13:17:57,332 ERROR    EventDrivenDebugger.updateHaltedStatusBar:1838    com.iconclude.dharma.runengine.RunException: Scriptlet error at line 3.
Code: var resp = myresults.includes("True");
Details: TypeError: Cannot read property "includes" from undefined in <eval> at line number 3

0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

If you are wanting to test the var myresults for "True" (case sensitive)
Try this:

myresults = scriptletContext.get("results");
resp = /True/.test(myresults); //tests the value of myresults for 'True' case sensitive

if (resp) {
 scriptletResponse = "success";
else {
 scriptletResponse = "failure";
}

View solution in original post

4 Replies
Highlighted
Trusted Contributor.
Trusted Contributor.

If you are wanting to test the var myresults for "True" (case sensitive)
Try this:

myresults = scriptletContext.get("results");
resp = /True/.test(myresults); //tests the value of myresults for 'True' case sensitive

if (resp) {
 scriptletResponse = "success";
else {
 scriptletResponse = "failure";
}

View solution in original post

Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Thank you Walt,

It worked like a charm!

I'd still like to know what is and what is not available with the scriptlet compare to NodeJS.

Is there more detail references on OO scriplet? Usualy HP was good at providing references for APIs, formal references.

Thanks again!

 

Pierre

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

v9 used RhinoScript flavor of javascript.  I imagine its the same for v10 but would need confirmation on that

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

In v10 there is Rhino and Nashorn. Nashorn is the one we recommend. 

Hope it helps,

Andrei Vasile Truta
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.