cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Screen Personas 3 SP11 - session executeScript function missing the property scriptResult

0 Kudos

Hello,

I've one script trying to use session.utils.executeScript to get some data.

For example, my script is like this

var oResult = session.utils.executeScript("<script_A_id>", null);
var data = oResult.scriptResult;

It used to work in the past since I could get the result from the property scriptResult.

However, I think after upgrading to SP11, the function executeScript doesn't return data anymore.

As I debug, it now returns true or false.

I remember it used to have this property scriptResult.

Now I can't find it anywhere.

Does anyone have any ideas?

Thanks.

Tri

Accepted Solutions (0)

Answers (1)

Answers (1)

oskarszandersons
Employee
Employee

Hi Tri,

Not sure if it ever had such property.

According to documentation session.utils.executeScript method:

"Executes a global script or another flavor script from within a script. Parameter "scriptId" is used to identify the script to be executed. The session object is available in the called script (variable name "session"). If the source parameter is not null, then it will be passed to the called script via the variable "source". The method returns a Boolean true if and only if the script returns a Boolean true. For all other script return values such as "undefined", "null", string values, object, etc., this methods returns a Boolean false."

You have two options on how to use script through session.utils.executeScript and exchange data with it.

1) Use session.utils.put / session.utils.get to store and retrieve data. This API is available in both flavor and global script invoked directly (or by any of available screen / control events) or through session.utils.executeScript / session.utils.exeucteScriptAsync methods.

2) Treat script executes through session.utils.executeScript as a function library and after it is executed from other script you can call functions defined in that script and recieve data as function result. Please refer to example scripts provided below. Usually global script is used as function library.

session.utils.executeScript("wnd[0]/scrptPersonas_005056AB61161EDB8BF9EF1265460864", null) 
var result = myFunctionLibrary.sum(10, 20);
console.log(result); 
(function() {
 var sum = function (a, b) {
 return a + b;
 };
 var sub = function (a, b) {
 return a - b;
 };
 window.myFunctionLibrary = {
 sum: sum,
 sub: sub,
 }
})(); 

Best Regards

Oskars Zandersons

0 Kudos

Hi Oskars,

Thanks for your comment.

I think in the past it had that property. In the old script, I only need to do this for example.

var result = [{
"name": "ABC"
}];
return result;

Then I can get the result from scriptResult.

Anyways, I'm using get and put.

Regards,

Tri