Skip to Content

Search a String for a variable

Nov 24, 2016 at 10:11 PM


avatar image
Former Member

Hello Experts,

I am attempting to look at a user status field and find a string to use as a variable in an if statement. I am using the following code but am getting an error stating the includes method isn't recognized.

var string = session.findById("wnd[0]/usr/subSCREEN_1:SAPLIQS0:1050/txtRIWO00-ASTXT").text ;
subString = "APPR"
output = string.includes(subString);
session.utils.log (ouput) ;

Any advice on how to accomplish this would be greatly appreciated. We are looking to hide buttons depending on user status.


Andrew McGrath

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Tamas Hoznek
Nov 24, 2016 at 10:50 PM

Well, assuming that the last line has a typo with ouput and your script contains output instead, the problem is that the session.utils.log method only accepts strings. So in this case, you could use something like

output = ""+string.includes(subString);

and this will result in the string true or false being written into the log.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the quick reply Tamas. I am receiving the following error after changing the code as you stated.

Error during script execution:Object doesn't support property or method 'includes'TypeError: Object doesn't support property or method 'includes'
at Function code (Function code:4:3)
at self.executeScriptInternal (
at sap.personas.scripting.executeScriptInternal (
at Anonymous function (eval code:1:594)

Is this method not available at my browser level possible?

The following script works fine for me and results in true:

var string = "S_APPR_WHATEVER" ;
subString = "APPR";
output = ""+string.includes(subString);

What you need should work well with if... something like

if (string.includes(subString)) { ... }