cancel
Showing results for 
Search instead for 
Did you mean: 

Screen Personas - Javascript Check if control exists

thomas_herz
Explorer
0 Kudos

Hello,

I'm a newbie to Screen Personas and try to get an Javascipt check if a certain control exists or not.

Is there a way to catch the error "control not found" and react (in Javascript) accordingly ?

Regards

Accepted Solutions (0)

Answers (4)

Answers (4)

pramod_teewaree
Explorer
0 Kudos

Currently on Personas 3.0,

I use try .. catch:

try {
  session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/cmbPersonas_146885648247470").enabled=true;
catch (lo_error) {
  //Error handling here
}
tamas_hoznek
Product and Topic Expert
Product and Topic Expert

session.idExists works fine to find out whether a control is present, so no real need for try...catch to do this.

thomas_herz
Explorer
0 Kudos

Hi,

I got the answer from SAP.

Instead of IdExists, you have to use idExists (lowercase i). Script validation wont find it, but UpperCase I leads to a dump.

Regards

thomas_herz
Explorer
0 Kudos

Hi Guys,

I tried the idExists

if(session.IdExists("wnd[0]/usr/subMAINSCREEN:SAPLOM_NAVFRAMEWORK_OO_OBJ:1200/subWORKSPACE:SAPLOM_NAVFRAMEWORK_OO_OBJ:0200/btnCLOSE_FOLDOUT_BUTTON"))

   {

    alert ("Close possible");

}

else

{

    alert ("Open possible");

}

Validation of the script showns no error. As soon as i launch the script i get the error

Error during script execution:
anonymous@[AppID:ZAPG2]>[Flavor:ZAPG2]>[Script:wnd[0]/scrptPersonas_1-detailansicht_close]:2:4
sap.personas.scripting.initialize/scriptingEngineModule/self.executeScriptInternal@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...
sap.personas.scripting.initialize/scriptingEngineModule/sap.personas.scripting.executeScriptInternal<@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...
sap.personas.fw.its.scripting.Runtime.prototype.execute/<@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...



Regards

peter_atkin
Active Contributor
0 Kudos

Thomas,

I'm new to SP too, and had a similar issue whereby I needed to know it a PM maintenance order tab was active or not.

The quickest way I found was to use the Object Selector tool in scripting to select a field. Then I check if that field is still active:

Here's the code I used which seems to work:


if (session.idExists("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/tabsTS_1100/tabpIHKZ/ssubSUB_AUFTRAG:SAPLCOIH:1120/subHEADER:SAPLCOIH:0154/ctxtCAUFVD-INGPR"))

  {

  session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/cmbPersonas_146885648247470").enabled=true;

  }

  else

  {

  session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/cmbPersonas_146885648247470").key=" ";

  session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:*/ssubSUB_LEVEL:SAPLCOIH:*/cmbPersonas_146885648247470").enabled=false;

  };

.

Any better suggestions would be most welcome.

PeteA

0 Kudos

Hi Pete,

The idExists is the right function to use to check if a control exists or not. The findById function returns an object with prototype functions corresponding to the object type.

Best regards

Kranthi

SAP Screen Personas Team

thomas_herz
Explorer
0 Kudos

Hi Guys,

I tried the idExists

if(session.IdExists("wnd[0]/usr/subMAINSCREEN:SAPLOM_NAVFRAMEWORK_OO_OBJ:1200/subWORKSPACE:SAPLOM_NAVFRAMEWORK_OO_OBJ:0200/btnCLOSE_FOLDOUT_BUTTON"))

   {

    alert ("Close possible");

}

else

{

    alert ("Open possible");

}

Validation of the script showns no error. As soon as i launch the script i get the error

Error during script execution:
anonymous@[AppID:ZAPG2]>[Flavor:ZAPG2]>[Script:wnd[0]/scrptPersonas_1-detailansicht_close]:2:4
sap.personas.scripting.initialize/scriptingEngineModule/self.executeScriptInternal@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...
sap.personas.scripting.initialize/scriptingEngineModule/sap.personas.scripting.executeScriptInternal<@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...
sap.personas.fw.its.scripting.Runtime.prototype.execute/<@http://sapa01t16.host.magwien.gv.at:8016/sap/bc/personas3/core/script/sap/personas/fw/its/scripting/...



Regards