cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Personas script error

john_p_joseph
Discoverer
0 Kudos

Hello,

I am new to the persona tool. And I have recorded a script to change the system password and assigned it to a button. The script is not working either through the button or in the editor. Please find below the error.

"

Error during script execution:
Cannot read property 'Type' of undefinedTypeError: Cannot read property 'Type' of undefined
at Object.oPrivate.getPropertyValue (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:7:17043)
at Object.get type [as type] (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:7:8210)
at sap.personas.scripting.scriptingEngine.oProtected.mObjects.GuiVComponent.get [as type] (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:7:18808)
at Object.sap.personas.scripting.scriptingEngine.oProtected.createObject (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:1:7916)
at sap.personas.scripting.scriptingEngine.oProtected.mObjects.GuiSession.sap.personas.scripting.scriptingEngine.GuiSession.findById (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:52:3404)
at eval ([AppID:SMEN]>[Flavor:Check_Reg]>[Script:wnd[0]/scrptPersonas_E6573FFEBC021ED993970CAC8E7F4014-GT25000]:6:9)
at Object.self.executeScriptInternal (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:65:10633)
at Object.sap.personas.scripting.executeScriptInternal (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/ScriptingEngine.js?20180514010622:65:12981)

at eval (http://sapecd.aero.org:3471/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/Runtime.js?eval:1:458)"

2019-03-25-12-54-48.jpg

Accepted Solutions (1)

Accepted Solutions (1)

eedens
Participant

Try replacing

session.findById("wnd[0]/tbar[0]/okcd").text = "su01";
session.findById("").sendVKey(0);

with

session.callTransaction("su01");

That'll execute a transaction call, rather than a macro to execute it from the Ok Code entry.

session.findById("").sendVKey(0);  

^ This fails, since the script doesn't know where you are wanting to press enter.

session.findById("wnd[0]").sendVKey(0); 

^ This version should work (does for me), since you're specifying the script to run in wnd[0].

For reference, here's the script that I set up for our help-desk a while back (it was my first personas project):

try {
  // Plug the Username and Password into variables.
  var usernameInit = session.findById("wnd[0]/usr/ctxtPersonas_152648653659742").text;
  var passwordNew = session.findById("wnd[0]/usr/boxPersonas_152648144695534/txtPersonas_152648647873818").text;
  var usernameUpper = usernameInit.toUpperCase();
  var passwordResetButton = session.findById("wnd[0]/usr/boxPersonas_152648144695534/btnPersonas_152648635258444");
  var accountUnlockedIcon = session.findById("wnd[0]/usr/boxPersonas_152648144695534/imagePersonas_152648633711112");
  var accountNameVerification = session.findById("wnd[0]/usr/boxPersonas_152648144695534/lblPersonas_152648631005071");
  // If there's values in the Username and Password fields, start a password reset.
  if (usernameUpper !== null && usernameUpper !== "" && passwordNew !== null && passwordNew !== "") {
    // Execute transaction SU01-User Maintenance
    session.callTransaction("su01");
    // Capitalize the Username
    session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = usernameUpper;
    // Click on the lock button
    session.findById("wnd[0]/tbar[1]/btn[29]").press();
    // Check if username is valid
    if (session.findById("wnd[0]/sbar").text === "E: User " + usernameUpper + " does not exist") {
      session.findById("wnd[0]/tbar[0]/btn[15]").press();
      accountNameVerification.text = usernameUpper + " does not exist.";
      usernameInit = "";
      passwordNew = "";
    }
    // Check if the user account is locked, and perform the necessary steps to unlock it when needed.
    else {
      if (session.findById("wnd[1]").title === "Lock User " + usernameUpper) {
        session.utils.log("true");
        session.findById("wnd[1]/tbar[0]/btn[12]").press();
        session.findById("wnd[0]/tbar[1]/btn[20]").press();
      } else {
        session.findById("wnd[1]/tbar[0]/btn[7]").press();
        session.findById("wnd[0]/tbar[1]/btn[20]").press();
      }
      // Enter the password variable into then popup window as the new password, and return to the home screen.
      session.findById("wnd[1]/usr/subPOPUP:SAPLSUID_MAINTENANCE:1101/pwdSUID_ST_NODE_PASSWORD_EXT-PASSWORD").text = passwordNew;
      session.findById("wnd[1]/usr/subPOPUP:SAPLSUID_MAINTENANCE:1101/pwdSUID_ST_NODE_PASSWORD_EXT-PASSWORD2").text = passwordNew;
      session.findById("wnd[1]/tbar[0]/btn[0]").press();
      session.findById("wnd[0]/tbar[0]/btn[15]").press();

      // Show the User Account Unlocked Icon
      accountUnlockedIcon.show();
      accountNameVerification.text = usernameUpper + " password reset.";
      usernameInit = "";
      passwordNew = "";
    }
  } else {
    // If you didn't enter anything into the Username and Password fields, then it laughs at you and doesn't do anything other than tell you.
    session.utils.alert("Please enter both a Username and Password.");
  }
  //Return Error Messages to the log, as well as a popup window.
} catch (oError) {
  var sErrorMessage = "An error occurred while executing the script. Details: \n";
  sErrorMessage += "Error ID: " + oError.name + "\n";
  sErrorMessage += "Error Message: " + oError.message;
  session.utils.alert(sErrorMessage);
  session.utils.log(sErrorMessage);
}

I have it running from the Easy Access screen in the webgui, and built a little interface for it to run from


Here's the editor view, as well as the variable names I used at the beginning of the script.

Answers (1)

Answers (1)

eedens
Participant
0 Kudos

Mind posting the script that goes along with this? The visible portion of the one in the picture looks to be a macro for entering check register data and selecting a variant.

john_p_joseph
Discoverer
0 Kudos

Hi Elliott,

Really appreciated for looking into my issue. And sorry, that I have posted a log from a wrong script. But I had the same "type" error for the below script as well.

session.findById("wnd[0]/tbar[0]/okcd").text = "su01";

session.findById("").sendVKey(0);

session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = "29774";

session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").setFocus(); session.findById("wnd[0]/tbar[1]/btn[20]").press();

I pass that error by removing the second line from the script (session.findById("").sendVKey(0) ) . Though it failed when I called the script from the persona flavor. see the below the error.

Note- The script works from the editor if i am on the SU01 t-code

Received "control not found" on batch step #2: {"post":"focus/wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME","__added_by_personas_scripting__":"X"} The complete batch was: 1: {"post":"okcode/ses[0]","content":"/nsu01","__added_by_personas_scripting__":"X"} 2: {"post":"focus/wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME","__added_by_personas_scripting__":"X"} 3: {"post":"action/3/wnd[0]/tbar[1]/btn[20]","__added_by_personas_scripting__":"X"} 4: {"get":"state/ur"}

Thanks

John