Absent Member.. DBR Absent Member..
Absent Member..
1609 views

Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters"

Jump to solution

I have a scriptlet that runs fine but isn't returning the execeted results.  The scriptlet is a in the Result, Filter.

 

This is a very simple example.

 

if (scriptletInput == "")

{

  var scriptletResult = "1";

  var test = "test"

}

 

What I want to be able to do is output the value for variable test when I hit the "Test All Filters" button.

 

Thanks,

Don

 

 

 

 

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters&qu

Jump to solution

Hi Don,

 

You can do it exactly as I demonstrated in my second code block; the trick is to initiate scriptletResult yourself.

 

var scriptletResult = new String();
var bEscape = false;

while(!bEscape) {
  scriptletResult += "my value\n";
  if(somethig == somecondition) {
    bEscape = true;
  }
}

 This would return n number of lines of "my value" until the escape condition is met. It's hard to be more specific without an example of the code you're using. If you're trying to get the result screen to update each iteration through you'll have to use the Javascript debugger in your local repository.

 

An alternative is to use an array

var aMyresults = [];
while(true) { // this will never exit of course
  aMyresults.push("my value");
}
scriptletResult = aMyresults.join("\n");

 

Hope this makes sense.

0 Likes
4 Replies
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters&qu

Jump to solution

The output which gets displayed is the value of scriptletResult. If your scriptlet is not the last filter in the chain, then pressing "Test All Filters" will display the value after the last filter has run.

 

So in your case

if(scriptletInput == "") {
  scriptletResult = "test";
}

Note that scriptletResult does not have to be defined, but can be; HPOO just returns toString() value of scriptletResult, so it can be any var type you want.

 

So you can do this

var scriptletResult = new String();
if(scriptletInput.length == 0) {
  scriptletResult = "1";
}
scriptletResult += "\nTest";

 

If you are trying to assign that to a flow variable called "test" then simply name your result as "test".

 

If you want to assign to the variable within the scriptlet you can do it via

scriptletContext.put(varName,varValue);

 though I highly recommend against assigning variable values with scriptletContext.

0 Likes
Absent Member.. DBR Absent Member..
Absent Member..

Re: Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters&qu

Jump to solution
Steve,

Thanks for the quick response.

I know I can do what you said, but that isn't the issue. In my real scriptlet I am in a while loop and I want to output every value as it goes through the loop. If I use the scriptletResult in the while loop it only returns the last value in the loop.

We have many items that we are looping over and the result should return three values. It returns the first and third but not the second. That is the reason I need to see what it is doing at every step on the loop.

Thanks!
Don
0 Likes
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters&qu

Jump to solution

Hi Don,

 

You can do it exactly as I demonstrated in my second code block; the trick is to initiate scriptletResult yourself.

 

var scriptletResult = new String();
var bEscape = false;

while(!bEscape) {
  scriptletResult += "my value\n";
  if(somethig == somecondition) {
    bEscape = true;
  }
}

 This would return n number of lines of "my value" until the escape condition is met. It's hard to be more specific without an example of the code you're using. If you're trying to get the result screen to update each iteration through you'll have to use the Javascript debugger in your local repository.

 

An alternative is to use an array

var aMyresults = [];
while(true) { // this will never exit of course
  aMyresults.push("my value");
}
scriptletResult = aMyresults.join("\n");

 

Hope this makes sense.

0 Likes
Absent Member.. DBR Absent Member..
Absent Member..

Re: Scriptlet Filter issue - Output what the scriptlet is doing when I hit "Test All Filters&am

Jump to solution

Steve,

 

That did it!

 

Thanks,

Don

 

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.