Skip to Content
avatar image
Former Member

Search a String for a variable

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • 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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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)) { ... }